1、单个json文件转换成csv文件
import json, codecs,csv # 这是因为版本的问题调用语句不匹配,更换调用语句为 with open('1fangyuan_shijiazhuang.json', 'r', encoding='UTF-8') as f2: load_dict = json.load(f2) print(type(load_dict)) ''' # 打开文件 f1 = open('shijiazhuang.csv', 'a', encoding='UTF-8') print("文件名为: ", f1.name) writer = csv.writer(f1) writer.writerow(['FYShengFen', 'FYtitle'])''' for i in load_dict: load_x = i['FYShengFen'] load_y = i['FYtitle'] # rint(type(load_y[0])) # print(load_x) # writer.writerow([load_x, load_y]) # 关闭文件 # f1.close()View Code