从 3 个列表的 zip 中创建字典

Сreate a dictionary from a zip of 3 lists

我有 3 个列表要放入字典中:

list1 = ['a', 'b', 'c']
list2 = [1, 2, 3]
list3 = [0.5, 0.3, 0.1]

传统上我可以用 list1list2

创建这样的字典
my_dict = dict(zip(list1, list2))
# {'a': 1, 'b': 2, 'c': 3}

但我想得到的是:

{'a': (1, 0.5), 'b': (2, 0.3), 'c': (3, 0.1)}

这没有用:

my_dict = dict(list1, zip(list2, list3))

您需要再添加一个 zip,因为 dict 构造函数接受 tuple 的列表,而不是两个 list

my_dict_3 = dict(zip(list1, zip(list2, list3)))