两个列表合并为一个字典函数list_dic(list1,list2)可以直接复制拿走
传入的参数为两个列表,list1准备作为key,list2准备作为value,key和value位置一一对应。
def list_dic(list1,list2):
'''
two lists merge a dict,a list as key,other list as value
:param list1:key
:param list2:value
:return:dict
'''
dic = dict(map(lambda x,y:[x,y], list1,list2))
return dic
if __name__ == '__main__':
list1 = ['111','222','333']
list2 = ['aaa','bbb','ccc']
print(list_dic(list1,list2))