擅长:python、mysql、java
<pre><code>>>> def f():
... a = "HELO"
... b = 1.0
... def w(c):
... return a,b,c
... return w
>>> w = f()
>>> w.__closure__
(<cell at 0xa05c4ac: str object at 0x9e91b74>, <cell at 0xa05c3bc: float object at 0xb733dde8>)
>>> w.__closure__[0].cell_contents
'HELO'
>>> w.__closure__[1].cell_contents
1.0
</code></pre>
<p>我从未见过在其他地方使用的<strong>单元格类型。它似乎是专门为保存闭包变量而构建的。</p>