函数可以做返回值–进行返回 视频p125
def func():print(123)def bar():return funcv = bar() # 将func函数名进行, 此时v = func
v()
name = 'oldboy'
def func():print(name)def bar():return funcv = bar()v()
def bar():def inner():print(123)return inner
v = bar()
v()
name = 'oldboy'
def bar():name = 'alex'def inner():print(name)return inner
v = bar()
v()
name = 'oldboy'
def bar(name):def inner():print(name)return inner
v1 = bar('alex') # { name=alex, inner } # 闭包,为函数创建一块区域(内部变量供自己使用),为他以后执行提供数据。
v2 = bar('eric') # { name=eric, inner }
v1()
v2()