📜  组合python代码示例

📅  最后修改于: 2022-03-11 14:45:43.621000             🧑  作者: Mango

代码示例1
# 1. Print all combinations 
from itertools import combinations

comb = combinations([1, 1, 3], 2)
print(list(combinations([1, 2, 3], 2)))
# Output: [(1, 2), (1, 3), (2, 3)]

# 2. Counting combinations
from math import comb
print(comb(10,3))
#Output: 120