【发布时间】:2021-02-26 18:17:33
【问题描述】:
我尝试漂亮地打印一个 JSON 文件,就像我有一个登录系统并且“数据”应该保存在那里。 但是如果我使用
with open('authentication.json', 'w+') as outfile:
json.dump(data, outfile)
输出
{"username": "censored", "password": "censored"}
在 JSON 文件中 但它应该在 JSON 中打印这个
{
"username": "censored",
"password": "censored"
}
【问题讨论】:
-
你试过阅读 json.dump() 的文档吗?
标签: python json pretty-print