zip 函数
zip 函数,看上去是打包的意思,其实功能是将多个可迭代对象,组合成一个个元组。
zip(iter1,iter2)
a,b = zip(*zip(iter1,iter2))
a = [1,2,3] b = [4,5,6] c = ['a','b','c','d'] # 将可迭代对象打包成一个个元组 print(zip(a,b)) print(list(zip(a,b))) print(list(zip(a,b,c))) # zip(*zip) 相反,提取出来 a1,a2 = zip(*zip(a,b)) print(list(a1)) a1,a2,a3 = zip(*zip(a,b,c)) print(list(a3))
http://www.runoob.com/python3/python3-func-zip.html