【发布时间】:2013-01-14 00:50:12
【问题描述】:
我有一个 Python 函数的一部分,看起来像:
for item in passedList:
tempDict = {}
tempDict ["first"] = item[0]
tempDict ["second"] = item[1]
tempDict ["third"] = item[2]
我期待的是:
{'first': 'item1', 'second': 'item2', 'third': 'item3'}
但是,我得到:
{'second': 'item2', 'first': 'item1', 'third': 'item3'}
这可能是一个非常简单的疏忽,但有什么想法会发生这种情况吗?
【问题讨论】:
标签: python list dictionary python-2.7