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)的方式
猜你喜欢
转载自blog.csdn.net/qq_33811662/article/details/80836110
今日推荐
周排行