同时遍历两个列表
如果两个列表等长
a=[1,2,3,4,5]
b=['a','b','c','d','e']
c = []
for i,j in zip(a,b):
c.append(str(j) + str(i))
list(map(lambda x,y:str(y)+str(x),a,b))
如果两个列表不等长,使用上面的方法,会取最短的列表长度
循环遍历最短的列表
from itertools import cycle
a=[1,2,3,4,5]
b=['a','b','c','d','e','f']
c = []
for i,j in zip(cycle(a),b):
c.append(str(j) + str(i))
list(map(lambda x,y:str(y)+str(x),cycle(a),b))

浙公网安备 33010602011771号