>>> d = {'A':1, 'b':2, 'c':3, 'D':4}
>>> d
{'A': 1, 'D': 4, 'b': 2, 'c': 3}
>>> d.items()
[('A', 1), ('c', 3), ('b', 2), ('D', 4)]
Does the order get randomized twice when I call d.items()? Or does it just get randomized differently? Is there any alternate way to make d.items() return the same order as d?
Edit: Seems to be an IPython thing where it auto sorts the dict. Normally dict and dict.items() should be in the same order.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…