2019-01-17

一.列表转换为字典:
1.使用zip函数:
a=[‘a1’,'a2','a3’,'a4’]
b=['b1','b2']
d=zip(a,b)
print(dict(d))
2.使用嵌套列表转换为字典:

a = ['a1','a2']
b = ['b1','b2']
c = [a,b]
print (dict(c))
dit ={}
for i inc:
dit ={}
for i in c:
dit[i[0]]=i[1]
print (dit)

你可能感兴趣的:(2019-01-17)