zip:字面意思就是打包的意思,目的也是打包
组装列表:
def get_dict(a:list,b:list): d = list(zip(a,b)) return d if __name__ == '__main__': # print(time_specific()) list1 = [1,2,3] list2 = [4,5,6] print(get_dict(list1,list2))
结果:
D:\Python\python.exe D:\highway\api\highway_apiframe\commons\wz.py [(1, 4), (2, 5), (3, 6)] 进程已结束,退出代码0
组装字典:
def get_dict(a:list,b:list): d = dict(zip(a,b)) return d if __name__ == '__main__': # print(time_specific()) list1 = [1,2,3] list2 = [4,5,6] print(get_dict(list1,list2))
结果:
D:\Python\python.exe D:\highway\api\highway_apiframe\commons\wz.py {1: 4, 2: 5, 3: 6} 进程已结束,退出代码0
标签:__,zip,list1,组装,list,list2,dict,字典 From: https://www.cnblogs.com/chengxiazuohua/p/17358785.html