python装饰器

    xiaoxiao2021-12-14  19

    装饰器就是加了个括号而已吧

    def route1(ref): print('begin route1') def route2(f): print('begin route2') def route3(*args, **kwargs): print('begin route3') print(*args, **kwargs) ret = f(*args, **kwargs) print('f', f) print('end route3') return ret print('route3', route3) print('end route2') return route3 print('route2', route2) print('end route1') return route2 @route1 def f1(rrr): print(rrr) print(f1) f1('aoeuaaaaaaaaa') #route1(f1)() @route1('ttt') def f2(rrr): print(rrr) print(f2) print('#########') f2('aoeaoe') #route1('ttt')(f2)()
    转载请注明原文地址: https://ju.6miu.com/read-965026.html

    最新回复(0)