from functools import wraps def My_decorate(func): @wraps(func) def fn(*args,**kwargs): print('decorate called') return func(*args,**kwargs) return fn @My_decorate def text(): print("test called") # decorate called # test called if __name__ == '__main__': print(text.__name__) # @wraps(func) 加了后 是原函数名 text print(text.__name__) #不加,变为 fn