import json
import csv
with open("json_file_path.json", "r") as f:
data = json.load(f)
head_list = list(data[0].keys())
json_values = []
for dict in data:
json_values.append(dict.values())
with open("csv_file_path.csv", "w", newline="") as f:
csv_writer = csv.writer(f)
csv_writer.writerow(head_list)
csv_writer.writerows(json_values)
Json文件转为CSV文件的Python实现
最新推荐文章于 2024-06-25 15:22:17 发布