【发布时间】:2012-05-12 05:05:40
【问题描述】:
是否有一种巧妙的方法可以在 Python 中迭代 两个 列表(不使用 列表推导)?
我的意思是,像这样:
# (a, b) is the cartesian product between the two lists' elements
for a, b in list1, list2:
foo(a, b)
代替:
for a in list1:
for b in list2:
foo(a, b)
【问题讨论】: