def test1():print("hello world")def test():print("in the tese")return test1 #test1就是函数名 就是一个内存地址 res就是test1的内存地址 res()才是运行test1res = test() #res = test(1)#没有return默认returnnone 没有打印print就是得到内存地#函数的作用域只跟函数声明时定义的作用域有关,跟函数的调用位置无任何关系
print(res())
#print a就是打印函数foo的内存地址 a()就是执行bar() 打印了name
作用域即忽视全局变量与局部变量,只运行对应的函数。
name='alex'def foo():name='lhf'def bar():name='wupeiqi'#函数嵌套是一层层嵌套,层层递进,除了最里面那一层少一层不都不行print(name)def tt():print(name)return ttreturn bar# bar=foo()# tt=bar()# print(tt)# tt()foo()()()#运行tt() 两个括号运行bar() 运行第一个箱子(第一个括号)得到第二个箱子,这个代码块有四个箱子