'''
Created on 2018年5月7日
@author: 2545519972@qq.com
'''
import os
import openpyxl
path = 'C:\\Users\\25455\\Desktop\\实验数据' #存放文件夹的路径
count = 0
filedic = {}
for fileName in os.listdir(path):
try:
for subfile in os.listdir(path + '\\' + fileName):
count = count + 1
name = os.path.splitext(subfile)[1]
if name in filedic:
filedic[name] += 1
else:
filedic[name] = 1
#print(str(count) + ' ' + name)
except:
continue
print(filedic)
#在当前目录下要先创立一个excel
wb = openpyxl.load_workbook('工作簿1.xlsx')
sheet = wb.get_sheet_by_name('Sheet1')
sheet['A1'] = '文件类型'
sheet['B1'] = '数量'
本内容试读结束,登录后可阅读更多
下载后可阅读完整内容,剩余1页未读,立即下载