python 函数返回函数

 

def hi(name="yasoob"):
    def greet():
        return "now you are in the greet() function"
    def welcome():
        return "now you are in the welcome() function"
    if name == "yasoob":
        return greet
    else:
        return welcome
a = hi()
print(a())

 

posted @ 2018-11-09 22:46  anobscureretreat  阅读(186)  评论(0编辑  收藏  举报