python json转csv格式
2020-03-27 本文已影响0人
happy_port
import json
import csv
import traceback
def convert():
try:
with open(".\daata.json",'r') as source:
regions = json.load(source)
with open('.\data.csv', 'w',newline='') as target:
writer = csv.writer(target)
writer.writerow(sheet_title)
writer.writerows(sheet_data)
print('转换成功.')
except Exception:
print('转换失败!')
print('traceback.format_exc():\n%s' % traceback.format_exc())
convert()