python: m个位置,每个位置有n种可能,求所有排列结果
>>> import itertools
>>> m, n = 3, 2
>>> paths = list(itertools.product(range(n), repeat=m))
>>> print(paths)
[(0, 0, 0), (0, 0, 1), (0, 1, 0), (0, 1, 1), (1, 0, 0), (1, 0, 1), (1, 1, 0), (1, 1, 1)]
>>> import itertools
>>> m, n = 3, 2
>>> paths = list(itertools.product(range(n), repeat=m))
>>> print(paths)
[(0, 0, 0), (0, 0, 1), (0, 1, 0), (0, 1, 1), (1, 0, 0), (1, 0, 1), (1, 1, 0), (1, 1, 1)]