Python zip 函数

Python 2016-07-14 21:57 暂无评论

健忘症患者备忘 →_→

>>> a = ['1', '2', '3', '4', '5', '6', '7', '8', '9']
>>> b = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i']
>>> for (c, d) in zip(a, b):
...     print 'a = %s, b = %s' % (c, d)
...
a = 1, b = a
a = 2, b = b
a = 3, b = c
a = 4, b = d
a = 5, b = e
a = 6, b = f
a = 7, b = g
a = 8, b = h
a = 9, b = i
暂无评论