from itertools import permutations, combinations
res = permutations(range(3), 2)
print(list(res))
# (0,1), (0,2), (1,0), (1,2), (2,0), (2,1)
res = permutations([0,0,1,1], 2)
print(set(list(res)))
res = combinations(range(4), 3)
print(list(res))
# --> (0, 1, 2), (0, 1, 3), (0, 2, 3), (1, 2, 3)
res = combinations([0, 0, 0, 1], 3)
print(set(res))
python内置库--排列组合
最新推荐文章于 2023-09-26 21:03:13 发布