-
排列
import itertools
mylist = list(itertools.permutations([1,2,3],2))
print(mylist)
输出结果:
[(1, 2), (1, 3), (2, 1), (2, 3), (3, 1), (3, 2)]
-
组合
import itertools
mylist = list(itertools.combinations([1,2,3],2))
print(mylist)
输出结果:
[(1, 2), (1, 3), (2, 3)]
总结:组合里是不重复的。