from itertools import product, permutations letters = ("A", "B") print(list(product(letters, range(2)))) print(list(permutations(letters)))
结果:
>>> [('A', 0), ('A', 1), ('B', 0), ('B', 1)] [('A', 'B'), ('B', 'A')] >>>
0