x = [1,2,3,4,5]
y = ['a','b','c','d','e']
p = {n:m for n in x for m in y}
print(p)
结果{1: 'e', 2: 'e', 3: 'e', 4: 'e', 5: 'e'}
print(dict(zip(x, y)))
{1: 'a', 2: 'b', 3: 'c', 4: 'd', 5: 'e'}
Sign in to make a reply
用户6610765864
x = [1,2,3,4,5]
y = ['a','b','c','d','e']
p = {n:m for n in x for m in y}
print(p)
结果{1: 'e', 2: 'e', 3: 'e', 4: 'e', 5: 'e'}