在 python3.3 中:
x = 1
print('global x =', x)
def f():
exec('x=2')
#x = 2
print('local in f() x =', x)
def g():
print('local in g() x =', x)
g()
f()
在 python3.3 为什么结果是这样的:
global x = 1
local in f() x = 1
local in g() x = 1
任何人都可以告诉我为什么 exec('x=2') in not equal x=2
'x=2' 和 exec('x=2') 有什么区别?
3倍