📜  python代码示例中的json编码

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

代码示例1
# How to encode JSON as a string
import json
print(json.dumps({'a': 1, 'b': 2}) # '{ "a": 1, "b": 2 }'
print(json.dumps({'b': 1, 'a': 2}, sort_keys=True, indent=4))
# {
#    "a": 2,
#    "b": 1
# }