name = "wangyue" def test1(): name= "in the test1" def bar(): name = "zhaozhen" print (name) return bar a = test1() print a a()#bar()
输出结果:<function bar at 0x1046840c8>
zhaozhen 分析:test1()赋值给变量a,此时a获取的是bar()函数的内存地址,输出a(),获取的是bar()函数的返回值
name = "wangyue" def test1(): name= "in the test1" def bar(): name = "zhaozhen" print (name) return bar a = test1() print a a()#bar()
输出结果:<function bar at 0x1046840c8>
zhaozhen 分析:test1()赋值给变量a,此时a获取的是bar()函数的内存地址,输出a(),获取的是bar()函数的返回值