def set_func(func): # print('装饰器开始装饰了...') def call_func(*args, **kwargs): print('....权限1.....') print('....权限2.....') return func(*args, **kwargs) # 这里没有return返回none return call_func @set_func # 等价于 test1 = set_func(test1) def test1(): print(".......这是test1......%d" % num) print(args) print(kwargs) return 'ok' ret = test1(100) # 这里相当于返回call_func函数的返回值 print(ret) ''' 通用装饰器: def set_func(func): # print('装饰器开始装饰了...') def call_func(*args, **kwargs): print('....权限1.....') return func(*args, **kwargs) return call_func @set_func def test1(): pass '''