码迷,mamicode.com
首页 > 编程语言 > 详细

python tips:dict的key顺序

时间:2019-06-14 19:51:11      阅读:107      评论:0      收藏:0      [点我收藏+]

标签:span   顺序   print   list   code   zip   结果   int   items   

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)]

 

python tips:dict的key顺序

标签:span   顺序   print   list   code   zip   结果   int   items   

原文地址:https://www.cnblogs.com/luoheng23/p/11025101.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!