Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有 4 个清单;
[1,3,6][1,5,9][1,2,4]['A','B','C']
我想像这样创建一个元组列表
[(1,1,1,'A'),(3,5,2,'B'),(6,9,4,'C')]
使用内置的 zip 功能:
>>> zip([1,3,6],[1,5,9],[1,2,4],['A','B','C']) [(1, 1, 1, 'A'), (3, 5, 2, 'B'), (6, 9, 4, 'C')]
它也适用于其他迭代。