def fun1_1():
x = [3]
def fun2_1():
x[0] *= x[0]
return x[0]
return fun2_1()
print(fun1_1())
def fun1_2():
x = 3
def fun2_2():
nonlocal x
x *= x
return x
return fun2_2()
print(fun1_2())
Python:实现闭包(closure)的方式
最新推荐文章于 2023-03-22 21:30:00 发布