import os
import xlwt # 操作excel模块
import sys
file_path = r'C:\Users\HP\Desktop\label-handwriting.xls'
f = xlwt.Workbook(encoding='utf-8', style_compression=0) # 新建一个excel
sheet = f.add_sheet('sheet1') # 新建一个sheet
pathDir = os.listdir(r'C:\Users\HP\Desktop\wang\SourceBmp') # 获取当前文件夹内所有文件目录
i = 0 # 将文件列表写入test.xls
for s in pathDir:
s = s.split('.')[0]
sheet.write(i, 0, s) # 参数i,0,s分别代表行,列,写入值
i = i + 1
print(file_path)
print(i) # 显示文件名数量
f.save(file_path)
提取文件名字到excel表中
最新推荐文章于 2024-07-18 17:29:46 发布