可能重复:
Python - merge items of two lists into a list of tuples
有两个清单
x = [1,2,3,4,5]
y = ['a','b','c','d','e']
如何获取列表
z = [(1, 'a'), (2, 'b'), (3, 'c'), (4, 'd'), (5, 'e')]
答案 0 :(得分:3)
z = zip(x,y)
将完成你的工作。
>>> x = [1,2,3,4,5]
>>> y = ['a','b','c','d','e']
>>> z = zip(x,y)
>>> z
[(1, 'a'), (2, 'b'), (3, 'c'), (4, 'd'), (5, 'e')]
答案 1 :(得分:2)
根据您的输入,内置函数zip(x, y)
将提供您想要的输出。
答案 2 :(得分:1)
x = [1,2,3,4,5]
y = ['a','b','c','d','e']
print zip(x,y)