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()函数的返回值

 

posted on 2018-04-25 14:09  wy0925  阅读(139)  评论(0编辑  收藏  举报