Python 修饰符@用法

时间:2022-05-20 16:59:46
def funA(desA):
    print("It's funA")

def funB(desB):
    print(desB( ))
    print("It's funB")

@funA
@funB
def funC():
    print("It's funC")
    return "return c"
    

结果:

Python 修饰符@用法

执行顺序是funA(funB(funC))     

1、先执行funC 结果 "return c" 放入到funB()运行  此时输出为  It's funC

2、funB(desb)   运行输出为   return c    It's funB

3、funA(desA)   运行因为desA 无返回值为None,所以输出为 It's funA