<p>我正在尝试<a href="https://stackoverflow.com/questions/233673/lexical-closures-in-python">Lexical closures in Python</a>中问题中的一段代码</p>
<pre><code>flist = []
for i in xrange(3):
def func(x): return x*i
flist.append(func)
for f in flist:
print f.func_closure
</code></pre>
<p>输出为:</p>
^{pr2}$
<p>不是吗?公司名称:</p>
<pre><code>(<cell at 0x9222d94: int object at 0x8cabdbc>,)
(<cell at 0x9222d94: int object at 0x8cabdbc>,)
(<cell at 0x9222d94: int object at 0x8cabdbc>,)
</code></pre>
<p>我使用以下代码得到了上述输出:</p>
<pre><code>flist = []
def actualFact():
for i in xrange(3):
def func(x): return x * i
flist.append(func)
for f in flist:
print f.func_closure
</code></pre>
<p>我使用的是python2.6.6(r266:842922010年9月15日,15:52:39)。在</p>