list1 = [1, 2, 3]
list2 = ['A', 'B', 'C']
list3 = ['X', 'Y', 'Z']
# 目标:{1:'A', 2:'B', 3:'C'}
dict_target = dict(zip(list1, list2))
# 打印结果:{1: 'A', 2: 'B', 3: 'C'}
# 目标:{1: ('A', 'X'), 2: ('B', 'Y'), 3: ('C', 'Z')}
# 先将list2 和list3 组合,取同一个位置的元素组成元组,再将多个元组组合生成列表
list_target = []
list4 = zip(list2, list3)
for i in list4:
list_target.append(i)
print(list_target) # 结果:[('A', 'X'), ('B', 'Y'), ('C', 'Z')]
dict_target = dict(zip(list1, list_target)) # 再将list1 和元组组成的列表 打包生成字典
print(dict_target)
# 打印结果:{1: ('A', 'X'), 2: ('B', 'Y'), 3: ('C', 'Z')}