-1
A
回答
2
Joachim Isaksson说的是正确的。
这将是有益的,如果你能提供一个代码片段,但你可以使用这样的事情:
import itertools
for a, b, c in itertools.izip (list1, list2, list3):
...
0
检查signature for zip。它接受任何数目iterables的:
拉链(* iterables)
是没有问题的zip
荷兰国际集团多个列表:
a, b, c = [1,2,3],[4,5,6],[7,8,9]
for (i,j,k) in zip(a,b,c):
print(i,j,k)
打印:
1 4 7
2 5 8
3 6 9
你甚至可以邮编0
或1
次迭代!
list(zip()) # []
list(zip([1,2,3])) # [(1,), (2,), (3,)]
1
zip
可用于任意多个列表。我只是这样做,它工作正常。
l1 = [1, 2, 3, 4]
l2 = [10, 20, 30, 40]
l3 = [100, 200, 300, 400]
l4 = [1000, 2000, 3000, 4000]
for x1, x2, x3, x4 in zip(l1, l2, l3, l4):
print(x1, x2, x3, x4)
输出:
1 10 100 1000
2 20 200 2000
3 30 300 3000
4 40 400 4000
相关问题
- 1. 的Python for循环遍历列表
- 2. 循环遍历Python中的列表
- 3. Python BeautifulSoup - 循环遍历多个页面
- 4. Django循环遍历列表
- 5. 循环遍历表列
- 6. 循环遍历python中的多个url请求的值列表
- 7. 循环遍历两个XML列表
- 8. python beautifulsoup循环遍历表格行
- 9. 循环遍历R中的多列
- 10. 多次循环遍历DataTable
- 11. xquery循环遍历列
- 12. MySQL循环遍历列
- 13. 循环遍历cf9中的列表
- 14. 循环遍历递归列表C
- 15. 循环遍历列表向量
- 16. 遍历表行的循环
- 17. Angularjs循环遍历表
- 18. Jquery循环遍历表行
- 19. 循环遍历表行
- 20. 循环遍历多个标签数组
- 21. 遍历列表(Python)
- 22. 循环遍历一个NSMutableArray
- 23. 循环遍历一个NSMutableDictionary
- 24. 循环遍历Python中的整数列表并返回两个新列表
- 25. Python,下一个循环遍历循环迭代
- 26. 循环遍历LinkedList
- 27. (Python)在嵌套for循环中列表遍历?
- 28. 用循环遍历Python,直到到达列表的末尾
- 29. python,遍历嵌套for循环中的列表
- 30. 如何使用for循环来循环遍历Python中的嵌套列表
你在哪里买的'zip'只接受两份名单? 'A = [1,2,3];列表(zip(a,a,a,a,a))给出了[(1,1,1,1,1),(2,2,2,2,2),(3,3,3, 3,3)]' –
但我已经在循环中尝试了(zip,gpxd_wpt_coordinates,gpxd_wpt_names,addressListAll)中的(item,name,address):''这里gpxd_wpt_coordinates,gpxd_wpt_names和addressListAll是列表。我得到的项目和名称的输出。但我得到一个错误,“addredd没有定义” – user8162
我猜'addredd'是一个错字?无论哪种方式,它看起来应该工作得很好。看到杰伊的回答下面,基本上你想做的事情。 –