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())

原文地址:https://www.cnblogs.com/sea-stream/p/9937568.html