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.
我有两个元组列表,我想将它们合并为一个 例如: List1 = [(a, 1),(b,2)] List2 =[(a, 3),(b,4)] 我希望结果结果 = [(a, 1,3),(b,2,4)]
>>> a = 1 >>> b = 3 >>> l1 = [(a, 1),(b,2)] >>> l2 = [(a, 3),(b,4)] >>> result = [] >>> for i1,i2 in zip(l1,l2): result.append(tuple([i1[0]])+tuple(i1[1:])+tuple(i2[1:])) >>> result [(1, 1, 3), (3, 2, 4)] >>>