Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/python-3.x/18.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 3.x 如何为阵列使用itertool产品_Python 3.x - Fatal编程技术网

Python 3.x 如何为阵列使用itertool产品

Python 3.x 如何为阵列使用itertool产品,python-3.x,Python 3.x,我有两个二维数组,例如array1和array2。我想重复一遍, 例如,repeat=2,则我希望输出为: (阵列1,阵列1),(阵列1,阵列2),(阵列2,阵列1),(阵列2,阵列2) 如何操作?只需将数组作为参数传递给itertools.product。有什么不起作用结果=列表(itertools.product((array1,array2),(array1,array2)) result = list(itertools.product((array1, array2), (array1

我有两个二维数组,例如
array1
array2
。我想重复一遍, 例如,
repeat=2
,则我希望输出为:

(阵列1,阵列1),(阵列1,阵列2),(阵列2,阵列1),(阵列2,阵列2)


如何操作?

只需将数组作为参数传递给
itertools.product
。有什么不起作用<代码>结果=列表(itertools.product((array1,array2),(array1,array2))
result = list(itertools.product((array1, array2), (array1, array2)))