读取目录下的文件列表写入 csv
#!/usr/bin/python3
# -*- coding: utf-8 -*-
# 导入CSV安装包
import csv
header = []
path = ''
with open('score.csv', 'w', encoding='UTF8', newline='') as f:
writer = csv.writer(f)
writer.writerow(header)
for root, dirs, files in os.walk(path):
for file in files:
writer.writerow(os.path.join(root, file))
f.close()
newline=‘’ 不保留空行