1. Key是文本的时候,如果sort_keys是False,则随机打印结果,如果sortkeys为true,则按顺序打印
2. Key是数字,则无论sort_keys为啥,都按顺序打印。
3. Key为文本和数字交加的时候,等同于文本。
>>> print json.dumps({"A": 5, "F": 8, "D": 7, "C": 9 }, sort_keys=False,indent=4, separators=(',', ':')) { "A":5, "C":9, "D":7, "F":8 } >>> >>> print json.dumps({"A": 5, "F": 8, "D": 7, "C": 9 }, sort_keys=True,indent=4, separators=(',', ':')) { "A":5, "C":9, "D":7, "F":8 } >>> >>> print json.dumps({"3": 5, "5": 8, "4": 7, "2": 9 }, sort_keys=False,indent=4, separators=(',', ':')) { "3":5, "2":9, "5":8, "4":7 } >>> >>> print json.dumps({"3": 5, "5": 8, "4": 7, "2": 9 }, sort_keys=True,indent=4, separators=(',', ':')) { "2":9, "3":5, "4":7, "5":8 } >>> >>> print json.dumps({3: 5, 5: 8, 4: 7, 2: 9 }, sort_keys=False,indent=4, separators=(',', ':')) { "2":9, "3":5, "4":7, "5":8 } >>> >>> print json.dumps({3: 5, 5: 8, 4: 7, 2: 9 }, sort_keys=True,indent=4, separators=(',', ':')) { "2":9, "3":5, "4":7, "5":8 } >>>