json.dumps中indent参数是设置json缩进量的
举例:
tmp = { "aaa" : "111", "bbb" : ‘222‘}
import json with open("tmp.txt", "w") as fp: fp.write(json.dumps(tmp,indent=4)) 打开tmp.txt查看效果
原文地址:https://www.cnblogs.com/VseYoung/p/python_json_dumps.html
时间: 2024-10-07 20:40:10