📜  python 使用缩进写入 json - Python 代码示例

📅  最后修改于: 2022-03-11 14:45:47.723000             🧑  作者: Mango

代码示例2
import json

# alphabetic dictionary
json_data = {hex(k): chr(k) for k in range(ord('a'), ord('z') + 1)}
# to file
with open("my_json.json", "w") as file:
    json.dump(json_data, file, indent=4, sort_keys=True)