import os
import csv
path = 'E:\Visual\VG/'
path_ = os.listdir(path)
fr=open('meta.csv','w+',newline='')#无newline=''每行会有空格
fr_csv=csv.writer(fr)
fr_csv.writerow(['json_Label','image_Source'])
for each_name in path_:
list = []
list.append(os.path.join('labels/',each_name.split('.')[0] + '.json'))
list.append(os.path.join('images/',each_name))
fr_csv.writerow(list)
fr.close()
python写入csv文件
最新推荐文章于 2022-05-08 21:10:37 发布