【发布时间】:2015-02-08 08:13:37
【问题描述】:
在尝试运行此代码时,我收到 UnboundLocalError: local variable referenced before assignment 错误。根据 LEGB 规则,这应该可以正常运行。
def xyz():
count = 1
def xyz_inner():
count += 1
print count
xyz_inner()
print count
【问题讨论】:
-
eli.thegreenplace.net/2011/05/15/… 我确定这里有重复
-
你的python版本是多少?
标签: python scope closures python-2.x