The following works well for cart_product([1,2,3], [a,b,c], [v])
, doesn't it also return duplicate cartesian product, if so, how to get unique cartesian products?
import itertools
def cart_product(*somelists):
for element in itertools.product(*somelists):
print element
also this doesn't seem to work when I pass in a list containing lists [ [1,2,3],[a,b,c],[v] ]
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…