python tips:dict的key顺序
Posted luoheng23
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了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)]
以上是关于python tips:dict的key顺序的主要内容,如果未能解决你的问题,请参考以下文章