【发布时间】:2014-06-23 07:21:10
【问题描述】:
我正在按照“Learn Python the Hard Way”一书中的练习 40 进行操作。我刚刚注意到以下几点:
In [15]: stuff
Out[15]:
{1: 'Wow',
2: 'Neato',
'age': 36,
'city': 'San Francisco',
'height': 74,
'name': 'Zed'}
In [16]: print stuff
{'city': 'San Francisco', 2: 'Neato', 'name': 'Zed', 1: 'Wow', 'age': 36, 'height': 74}
为什么两个输出中字典项的顺序有差异?
【问题讨论】:
-
如果你对字典内部感兴趣,你应该看the Mighty Dictionary。
标签: python python-2.7 dictionary printing