Python zip()函数的使用

zip() 函数用于将可迭代的对象作为参数,将对象中对应的元素打包成一个个元组.

1 # zip 打包操作
2 a = (1,2,3)
3 b = (4,5,6)
4 c = zip(a, b)
5 print (list(c))
6 
7 # 搭配for循环,支持迭代操作方法
8 for (x, y) in zip(a, b):
9     print (x,y,'-->',x*y)
原文地址:https://www.cnblogs.com/demo-deng/p/7515323.html