阅读背景:

python zip 要迭代的元素在多个不同的序列,如何对其迭代

来源:互联网 
#the values we want to iterate is in different lists
#use zip to pack them	
from itertools import zip_longest
xpts = [1,5,4,2,17]
ypts = [101, 78, 37, 15, 62, 99]
for x, y in zip(xpts, ypts):
	temp = (x,y)
	print(temp)


a = [1,2,3]
b = ['w','x','y','z']
for i in zip(a,b):
	print(i)
	print(i[0])
	print(i[1])
	print(type(i))


for i in zip_longest(a,b,fillvalue=0):
	print(i)#the values we want to iterate is in different 



你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: