现有一个需求要将json转成excel,使用python将其转为csv格式,使用excel打开即可. import json import csv import codecs f = open('test.json') data = json.load(f) #print(data) f.close() f = codecs.open('test.csv', 'w', 'utf_8_sig')#解决写入csv时中文乱码 writer=csv.writer(f); for item in data…
Python标准库之csv(1) 1.Python处理csv文件之csv.writer() import csv def csv_write(path,data): with open(path,'w',encoding='utf-8',newline='') as f: writer = csv.writer(f,dialect='excel') for row in data: writer.writerow(row) return True 调用上面的函数 data = [ ['Name'…
读取csv文件: def readCsv(): rows=[] with file(r'E:\py\py01\Data\system.csv','rb') as f: reads=csv.reader(f) for i in reads: rows.append(i) print rows return rows写入csv文件: def writer(): with file(r'E:\py\py01\Data\system.csv','wb') as f: writer=csv.writer(…