📜  python获取列表的所有组合 - Python代码示例

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

代码示例4
def combinations(iterable, r):
    pool = tuple(iterable)
    n = len(pool)
    for indices in permutations(range(n), r):
        if sorted(indices) == list(indices):
            yield tuple(pool[i] for i in indices)