【发布时间】:2017-09-22 14:53:54
【问题描述】:
所以我有以下列表:
test = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]
我想遍历内部列表中的ith 元素。我可以使用zip:
for x, y, z in zip(test[0], test[1], test[2]):
print(x, y, z)
返回:
1 4 7
2 5 8
3 6 9
有没有一种更简洁、更 Pythonic 的方式来做到这一点? zip(test, axis=0) 之类的东西?
【问题讨论】:
-
for x, y, z in zip(*test):
标签: python list for-loop iterator zip