python tips:dict的key顺序

python3.6+版本中,dict的键值保持插入有序。

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

输出结果

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

 

posted @ 2019-06-14 19:16  luoheng  阅读(1699)  评论(0编辑  收藏  举报