Python虚拟机框架(Python 源码剖析第八章)
时间:2010-11-17 来源:Ray Z
error 1 >>> a = 1
2 >>> def g():
3 print a
4
5
6 >>> def f():
7 print a
8 a = 2
9 print a
10
11
12 >>> g()
13 1
14 >>> f()
15
16 Traceback (most recent call last):
17 File "<pyshell#11>", line 1, in <module>
18 f()
19 File "<pyshell#9>", line 2, in f
20 print a
21 UnboundLocalError: local variable 'a' referenced before assignment
相关阅读 更多 +