列表转字典
两个列表转为一个
现在有两个列表,list1 = ['key1','key2','key3']和list2 = ['1','2','3'],把他们转为这样的字典:{'key1':'1','key2':'2','key3':'3'}
举例:
name=["xiaoming","xiaolan"]
age=[18,20]
print dict(zip(name,age))
结果:{'xiaoming': 18, 'xiaolan': 20}
将嵌套列表转为字典,
list = [['xiaoming',18],['xiaolan',20]]
dict(list)
结果:{'xiaoming': 18, 'xiaolan': 20}