import os
#文本记录表格
myTxtRecordTableList=[]
#公司名提取
def getCompanyName(str_fileName):
return "comp"
#日期提取
#项目文件名提取
#宽高数量提取
#单价提取
#其他收费提取
fileLoad=input("请输入路径:_")
filenamesList=[]
for folderName, subfolders, filenames in os.walk(fileLoad):
#print('The current folder is ' + folderName)
'''for subfolder in subfolders:
#目录
print('SUBFOLDER OF ' + folderName + ': ' + subfolder)
'''
for filename in filenames:
#全路径文件名
print('FILE INSIDE ' + folderName + ': '+ filename)
print(len(filename))
myTxtRecordTableList.append([getCompanyName(filename),'01-09',filename,1.00,2.00,12,14.00,3.5])
for i in range(len(myTxtRecordTableList)):
print(myTxtRecordTableList[i][0]+'\t'+myTxtRecordTableList[i][1]+
'\t'+myTxtRecordTableList[i][2]+'\t'+str(myTxtRecordTableList[i][3])+'\t'+str(myTxtRecordTableList[i][4])+'\t'+str(myTxtRecordTableList[i][5])+'\t'+str(myTxtRecordTableList[i][6]))
使用python实现迭代遍历文件夹下的文件
辉宇工作室原创文章