python3 美化输出json import json a={'4': 5, '6': 7} print(json.dumps(a, sort_keys=True, indent=4)) 输出 { "4": 5, "6": 7 }