为什么第一个打印语句没有给我'5 = 3'?这是来自约翰古塔格的书。我无法理解它。
顺便说一句,它看起来像这样:
3 = 4
2 = 4
1 = abc
4 = 4
5 = 3
6 = <function g at 0x026B22F0>
1 = abc
脚本:
def f(x):
def g():
x = 'abc'
print '1 =',x
def h():
z = x
print '2 =',z
x = x+1
print '3 =',x
h()
g()
print '4 =', x
return g
x = 3
z = f(x)
print '5 =',x
print '6 =',z
z()