擅长:python、mysql、java
<p>使用<a href="http://docs.python.org/library/itertools.html#itertools.product" rel="nofollow noreferrer">^{<cd1>}</a>:</p>
<pre><code>>>> site_range=[0,1]
>>> list(product(site_range, repeat=3))
[000 001 010 011 100 101 110 111]
</code></pre>
<p><strong>编辑</strong>正如@Glenn Maynard在评论中指出的那样,这不是笛卡尔积。为此,您必须检查<a href="https://stackoverflow.com/questions/4013730/how-do-i-generate-a-cartesian-product-of-several-variables-using-python-iterators/4013768#4013768">his answer</a>。在</p>