即 nCr,which represents “n choose r”

import itertools

things = ["苹果", "桃子", "梨"]

print(list(itertools.combinations(things, 2)))

print结果:
[('苹果', '桃子'), ('苹果', '梨'), ('桃子', '梨')]

更多用法:https://docs.python.org/3/library/itertools.html

python,从n个不同元素中取出r个元素的所有不同组合_html