擅长:python、mysql、java
<p>使用<a href="http://docs.python.org/2/library/itertools.html#itertools.combinations" rel="nofollow">^{<cd1>}</a>进行此操作:</p>
<pre><code>import itertools as it
ans = it.combinations([1, 2, 3, 4, 5, 6, 7], 6)
</code></pre>
<p>结果应该是:</p>
^{pr2}$
<p>如果以后需要打印数字,很容易:</p>
<pre><code>for r in ans:
print ' '.join(str(s) for s in r)
=> 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>