函数闭包 #嵌套函数里,内部函数使用外部函数变量,并且外函数返回值是内函数的引用,这样就构成了闭包
a=23
def hanshu():
b=10
print(b)
def hanshu1():
c=a+b
print(c) #使用了外部函数变量
return hanshu1
test=hanshu() #外部函数
test()#调用内部函数

函数闭包 #嵌套函数里,内部函数使用外部函数变量,并且外函数返回值是内函数的引用,这样就构成了闭包
a=23
def hanshu():
b=10
print(b)
def hanshu1():
c=a+b
print(c) #使用了外部函数变量
return hanshu1
test=hanshu() #外部函数
test()#调用内部函数