x = 10
def foo():
x = 100
# print(x)
def bar():
nonlocal x
# global x
x = "kkk"
def ter():
nonlocal x
x = "yyy"
ter()
def xxx():
nonlocal x
x = 1234
xxx()
bar()
print(x)
foo()
函数的作用域nonlocal,来猜猜这代码会输出什么答案?
最新推荐文章于 2025-08-04 19:52:09 发布