I am trying to understand the differences between python dictionaries in python 3.6.7
and python 3.5.2
. The way they store the order of key-value pairs seems different.
For example, assume there is a dictionary named di
:
di = {'a':1,'A':1,'b':2, 'B':2, 'c':3, 'C':3}
in Python 3.5.2
, when I print di
, the output is:
{'C': 3, 'a': 1, 'A': 1, 'B': 2, 'c': 3, 'b': 2}
However, in Python 3.6.7
, it is:
{'a': 1, 'A': 1, 'b': 2, 'B': 2, 'c': 3, 'C': 3}
What have been changed between the two versions?
How can I make my code order the result of python 3.6.7
similar to 3.5.2
's.
P.S. I know that there is actually no order in Python dictionary. The term order
here is used to make the reader easy to understand my question.
Thank you.