因为我想将 dict 解码为 json,但我发现输出顺序不是我想要的,然后我做了这样的测试:
a = {'a':'1st','ab':'2nd'}
print(a)
a = {'b':'1st','bc':'2nd'}
print(a)
a = {'c':'1st','cd':'2nd'}
print(a)
a = {'d':'1st','de':'2nd'}
print(a)
a = {'e':'1st','ef':'2nd'}
print(a)
a = {'f':'1st','fg':'2nd'}
print(a)
输出是
{'a': '1st', 'ab': '2nd'}
{'b': '1st', 'bc': '2nd'}
{'c': '1st', 'cd': '2nd'}
{'de': '2nd', 'd': '1st'}
{'ef': '2nd', 'e': '1st'}
{'fg': '2nd', 'f': '1st'}
因为 d 在 ascii 中是 100?
如何解释?我可以更改迭代顺序吗?