import json
#读取JSON文件
with open(r"E:\MyDataset\output\train.json",'r') as f:
json_str=f.read()
#解析JSON字符串为Python对象
obj=json.loads(json_str)
for i in range(len(obj['images'])):
a=json.dumps(obj,indent=4)
with open(r"E:\MyDataset\output\train2.json",'w') as f:
f.write(a)
(记笔记)如何把json文件里数字有序分行显示
最新推荐文章于 2023-08-21 15:29:02 发布