我有一个包含 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)