说我有两个列表。通过Python中的循环遍历键和值到字典3.3
>>> List1 = ['This', 'is', 'a', 'list']
>>> list2 = ['Put', 'this', 'into', 'dictionary']
>>> d = {}
我怎么会用一个循环,使列表1键和列表2的值,使每个索引将自己存入字典,所以作为一个例子...
>>> d = {'This': 'Put', 'is': 'this', 'a': 'into', 'list': 'dictionary'}
http://stackoverflow.com/questions/209840/map-two-lists-into-a-dictionary-in-python –
你知道'zip'吗?如果是这样,这是微不足道的。如果没有,请阅读[文档](http://docs.python.org/3/library/functions.html#zip),然后它是微不足道的。 – abarnert