使用zip函数完成转换
a = ['a1','a2','a3','a4']
b = ['b1','b2','b3']
d = zip(a,b)
print(dict(d)) # {'a1': 'b1', 'a2': 'b2', 'a3': 'b3'}
dit = {'name':'zxf',
'age':'22',
'gender':'male',
'address':'shanghai'}
# 将字典的key转换成列表
lst = list(dit)
print(lst) # ['name', 'age', 'gender', 'address']
# 将字典的value转换成列表
lst2 = list(dit.values())
print(lst2) # ['zxf', '22', 'male', 'shanghai']
参考链接:
https://blog.csdn.net/loner_fang/article/details/80940600