使用未知数量的args调用itertools.product

时间:2013-06-21 13:28:02

标签: python

我希望这很简单。

有没有可能用一个尚未(不是硬编码)的非基本数量的参数来调用itertools.product?

这样的事情:

itertools.product(x[0],x[1],x[2],....)

并且x的维度不能硬编码

谢谢!

3 个答案:

答案 0 :(得分:3)

尝试:

itertools.product(*x)

即。我们unpack the argument list

答案 1 :(得分:2)

您可以使用

itertools.product(*x)

答案 2 :(得分:0)

查找*args and **kwargs?

a = [1,2,3]
b = [2,3,4]
c= [a,b]

itertools.product(*c)

您可以使用*

传递参数数组
相关问题