函数作用域

def test1():
    print('in the test1')
def test():
    print('in the test')
    return test1

res=test()#先执行test()然后执行test1()输出,
print(res())#最后执行的是test1() 没有return默认值为none不加括号返回的是地址,加了括号()就不是地址执行函数。

猜你喜欢

转载自www.cnblogs.com/wfl9310/p/8954732.html