python tips: key sequence of dict

python3.6 + version, dict the key remains inserted in order.

1 t = list(range(10))
2 b = t[:]
3 d = dict(zip(t, b))
4 print(list(d.items()))

Output

1 [(0, 0), (1, 1), (2, 2), (3, 3), (4, 4), (5, 5), (6, 6), (7, 7), (8, 8), (9, 9)]

 

Guess you like

Origin www.cnblogs.com/luoheng23/p/11025101.html