python装饰器简单操作

#装饰器简单操作
def a(func):
    def a_inner(str):
        print(str)
        func()
    print('-----')
    return a_inner

# @a装饰器相当于b = a(b)
@a
def b():
    print('hallo b')
b('hello a')

猜你喜欢

转载自blog.csdn.net/weixin_42670402/article/details/82313125