打包聚合各个可迭代对象的迭代器

5年以前  |  阅读数:836 次  |  编程语言:Python 
>>> x = [3,2,1]
>>> y = [4,5,6]
>>> list(zip(y,x))
[(4, 3), (5, 2), (6, 1)]
>>> for i,j in zip(y,x):
 print(i,j)

4 3
5 2
6 1

Copyright© 2013-2020

All Rights Reserved 京ICP备2023019179号-8