擅长:python、mysql、java
<p>是的,<code>count</code>变量的作用域只在主循环中。在</p>
<p><code>if main</code>循环中的<code>count</code>变量与<code>permuate</code>函数中的计数变量不同。在</p>
<p>如果您想从<code>permuate</code>函数获得count变量的值,那么从函数返回count值并接受in count变量。在</p>
<p><strong>演示:</strong></p>
<pre><code>>>> count = 10
>>> def test(count):
... count += 1
... print "In test:", id(count)
... return count
...
>>> count = test(count)
In test: 149784632
>>> count
11
</code></pre>