您不需要
n事先知道使用
itertools.product
>>> import itertools>>> s=[ [ 'a', 'b', 'c'], ['d'], ['e', 'f'] ]>>> list(itertools.product(*s))[('a', 'd', 'e'), ('a', 'd', 'f'), ('b', 'd', 'e'), ('b', 'd', 'f'), ('c', 'd', 'e'), ('c', 'd', 'f')]
您不需要
n事先知道使用
itertools.product
>>> import itertools>>> s=[ [ 'a', 'b', 'c'], ['d'], ['e', 'f'] ]>>> list(itertools.product(*s))[('a', 'd', 'e'), ('a', 'd', 'f'), ('b', 'd', 'e'), ('b', 'd', 'f'), ('c', 'd', 'e'), ('c', 'd', 'f')]