定义变量:
my_mapping = {'a': 23, 'b': 42, 'c': 0xc0ffee}
使用json格式化输出:
import json
print(json.dumps(my_mapping, indent=4, sort_keys=True))
输出结果:
{
"a": 23,
"b": 42,
"c": 12648430
}
my_mapping = {'a': 23, 'b': 42, 'c': 0xc0ffee}
import json
print(json.dumps(my_mapping, indent=4, sort_keys=True))
{
"a": 23,
"b": 42,
"c": 12648430
}
评论区