苗火 Nicholas
[python]Python to read directorys and write sheet (excel)
2021-5-20 萧
import os
import xlwt

def file_name(file_dir):
for root, dirs, files in os.walk(file_dir):
list_files(files)


def list_files(files):
workbook = xlwt.Workbook(encoding = 'utf-8')
worksheet = workbook.add_sheet('Nicholas')
lines = 1
for item in files:
print(item)
items = item.split("_")
print(items)
cols = 1
for col in items:
if cols==1:
col = col[8:10] + ':' + col[10:12] + ':' + col[12:14] + '.' + col[14:]
worksheet.write(lines,cols,label=col)
cols += 1

lines += 1

workbook.save('nicholas.xls')

file_name("./dirty")
发表评论:
昵称

邮件地址 (选填)

个人主页 (选填)

内容