可能重复:
如何将Python字典转换为元组列表?
我正在尝试将Python字典转换为Python列表,以便执行一些计算.
#My dictionary
dict = {}
dict['Capital']="London"
dict['Food']="Fish&Chips"
dict['2012']="Olympics"
#lists
temp = []
dictList = []
#My attempt:
for key, value in dict.iteritems():
aKey = key
aValue = value
temp.append(aKey)
temp.append(aValue)
dictList.append(temp)
aKey = ""
aValue = ""
Run Code Online (Sandbox Code Playgroud)
这是我的尝试......但我无法弄清楚什么是错的?