如何创建具有三个列表的所有排列?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)