前向引用之'函数即变量'

def action():
    print 'in the action'
    logger()
action()
报错NameError: global name 'logger' is not defined


def logger():
    print 'in the logger'
def action():
    print 'in the action'
    logger()
 
action()
 

def action():
    print 'in the action'
    logger()
def logger():
    print 'in the logger'
 
action()

 

posted @ 2019-05-13 11:33  clever1  阅读(188)  评论(0编辑  收藏  举报