今天爱分享给大家带来python如何映摄两个列表成为一个字典【面试题详解】,希望能够帮助到大家。
两个列表
keys = ('name', 'age', 'food')
values = ('Monty', 42, 'spam')
如何得到
dict = {'name' : 'Monty', 'age' : 42, 'food' : 'spam'}
使用zip
>>> keys = ['a', 'b', 'c']
>>> values = [1, 2, 3]
>>> dictionary = dict(zip(keys, values))
>>> print dictionary
{'a': 1, 'b': 2, 'c': 3}
原文链接:https://itblood.website/4456.html,转载请注明出处。

![郊区王子v1.1.0 官中版[PC+安卓/5.58G/更新]Prince of Suburbia [Mini DLC] [欧美SLG/汉化/沙盒]](/wp-content/uploads/replace/2025/09/23/5e61f24843054fd143e201ddc0681946.webp)