蟒蛇保存json用缩进

代码示例

2
0

N

print(json.dumps(dict, indent=4))
2
0

N

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)

类似页面

带有示例的类似页面

其他语言

此页面有其他语言版本

Русский
..................................................................................................................
English
..................................................................................................................
Italiano
..................................................................................................................
Polski
..................................................................................................................
Română
..................................................................................................................
한국어
..................................................................................................................
हिन्दी
..................................................................................................................
Français
..................................................................................................................
Türk
..................................................................................................................
Česk
..................................................................................................................
Português
..................................................................................................................
ไทย
..................................................................................................................
Español
..................................................................................................................
Slovenský
..................................................................................................................
Балгарскі
..................................................................................................................
Íslensk
..................................................................................................................