擅长:python、mysql、java
<p>如果我理解您的问题,请继续使用<a href="http://docs.python.org/2/library/itertools.html" rel="nofollow">itertools</a>模块中的<a href="http://docs.python.org/2/library/itertools.html#itertools.combinations" rel="nofollow">combinations</a>函数。在您的情况下,您将得到:</p>
<pre><code>>>> import itertools
>>> list(itertools.combinations([1,2,3,4,5,6,7],6)
[(1, 2, 3, 4, 5, 6)
(1, 2, 3, 4, 5, 7)
(1, 2, 3, 4, 6, 7)
(1, 2, 3, 5, 6, 7)
(1, 2, 4, 5, 6, 7)
(1, 3, 4, 5, 6, 7)
(2, 3, 4, 5, 6, 7)]
</code></pre>
<p>我想这就是你想要的。在</p>
<p>请记住,<code>combinations</code>函数的输出是一个生成器。在</p>