问题描述:

This question already has an answer here:

  • Map two lists into a dictionary in Python

    9 answers

网友答案:
>>> arr1 = ['name','age','sex']
>>> val1 = ['Jone','20','male']
>>> dict(zip(arr1, val1))
{'age': '20', 'name': 'Jone', 'sex': 'male'}
网友答案:

With python 2.7 onwards you could use dictionary comprehension

val = { k: v for k, v in zip(arr1, val1) }
网友答案:
val = {}
for i in range(len(arr1)):
    val[arr1[i]] = val1[i]
相关阅读:
Top