Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/291.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/batch-file/6.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_Python - Fatal编程技术网

如何创建具有三个列表的所有排列?python

如何创建具有三个列表的所有排列?python,python,Python,假设我有三张清单 a=[1,2,3,4,5,6,7,8,9,10] b=[1,2,3,4,5,6,7,8,9,10] c=[1,2,3,4,5,6,7,8,9,10] 我想用a、b和c创建所有排列 from itertools import permutations a=[1,2,3,4,5,6,7,8,9,10] b=[1,2,3,4,5,6,7,8,9,10] c=[1,2,3,4,5,6,7,8,9,10] perm = permutations([a,b,c]) for i in l

假设我有三张清单

a=[1,2,3,4,5,6,7,8,9,10]
b=[1,2,3,4,5,6,7,8,9,10]
c=[1,2,3,4,5,6,7,8,9,10]
我想用a、b和c创建所有排列

from itertools import permutations
a=[1,2,3,4,5,6,7,8,9,10]
b=[1,2,3,4,5,6,7,8,9,10]
c=[1,2,3,4,5,6,7,8,9,10]

perm = permutations([a,b,c])
for i in list(perm): 
   print (i)
这给

([1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10])
([1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10])
这不是我要找的

我在寻找解决办法

[1,1,1],[1,2,1],[1,3,1],[1,4,1].....

这可能吗

我想您正在寻找产品:

from itertools import product
a=[1,2,3,4,5,6,7,8,9,10]

perm = product(a, repeat=3)
for i in list(perm): 
   print (i)
如果a、b、c不相同,则使用:
产品(a、b、c)