小编DCh*_*aka的帖子

python itertool组合列表不完整

我有一个包含 11 个元素的列表,我需要其中长度为 4 的所有可能的元组。于是我在Itertools中找到了这个函数combinations

然而,它只提供 210 个元组,而不是 11^4 = 14641。我检查了该print函数,发现其中许多元组丢失了。

我能做什么,或者有什么问题?

atom = [0, 5, 6, 12, 10, 13, 11, 9, 1, 2]
atoms = list(itertools.combinations(atom,4))
Run Code Online (Sandbox Code Playgroud)

python combinations python-itertools

1
推荐指数
1
解决办法
1741
查看次数

标签 统计

combinations ×1

python ×1

python-itertools ×1