>>> a = [1,2,3,4,5]
>>> b = [9,8,7,6,5]
>>> length = len(a) if len(a)<len(b) else len(b)
>>> length
5
>>> c = zip(a,b)
>>> c
[(1, 9), (2, 8), (3, 7), (4, 6), (5, 5)]
>>>zip(*c)
[(1,2,3,4,5), (9,8,7,6,5)]
>>> d = []
>>> for x,y in zip(a,b):
d.append(x+y)
>>> d
[10, 10, 10, 10, 10]
时间: 2024-11-06 04:54:01