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查看效果
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查看效果