这可能是个愚蠢的问题,所以我会尽量简单
我有一个不同数量的列表(x)的列表,我试图将每个列表传递给函数itertools.product(),但我无法让它工作
x = [[a, b, c], [d, e, f], [g, h, i]]
itertools.product(x[0], x[1], x[2]...)
我试过:
itertools.product(x[n] for n in range(len(x)))
itertools.product(n for n in x)
我的职能部门很可能会:
output = []
for product in itertools.product(x[n] for n in range(len(x))):
output.append(product)
output """--> [(a, d), (a, e)...]"""
非常感谢
Same as always.
使用unpacking:
相关问题 更多 >
编程相关推荐