-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循环遍历列表
- 2. 的Python for循环遍历列表
- 3. 循环遍历Python中的列表
- 4. Python BeautifulSoup - 循环遍历多个页面
- 5. 循环遍历python中的多个url请求的值列表
- 6. 循环遍历表列
- 7. Django循环遍历列表
- 8. Swift循环遍历列表
- 9. 循环遍历两个XML列表
- 10. 循环遍历一个列表,只循环某个类的li?
- 11. python循环遍历行数
- 12. python beautifulsoup循环遍历表格行
- 13. 循环遍历R中的多列
- 14. 多次循环遍历DataTable
- 15. 遍历多个列表,并在Python
- 16. MySQL循环遍历列
- 17. xquery循环遍历列
- 18. Pythonic方式遍历for循环中的多个列表?
- 19. 如何遍历使用在Django多个列表for循环
- 20. 循环列表遍历引擎
- 21. 循环遍历C中的列表#
- 22. 循环遍历c#中的列表#
- 23. 循环遍历递归列表C
- 24. 循环遍历列表对的元素
- 25. 链接列表的循环遍历
- 26. 循环遍历列表向量
- 27. 如何循环遍历列表
- 28. for循环并遍历列表
- 29. 循环遍历cf9中的列表
- 30. jquery循环遍历列表并替换
你在哪里买的'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'是一个错字?无论哪种方式,它看起来应该工作得很好。看到杰伊的回答下面,基本上你想做的事情。 –