不加:
from functools import wraps def my_decorator(func): def wper(*args, **kwargs): ‘‘‘decorator‘‘‘ print(‘Calling decorated function...‘) return func(*args, **kwargs) return wper @my_decorator def example(): """Docstring""" print(‘Called example function‘) print(example.__name__, example.__doc__)#wper decorator
加:
from functools import wraps def my_decorator(func): @wraps(func) def wper(*args, **kwargs): ‘‘‘decorator‘‘‘ print(‘Calling decorated function...‘) return func(*args, **kwargs) return wper @my_decorator def example(): """Docstring""" print(‘Called example function‘) print(example.__name__, example.__doc__)#example Docstring
装饰器修复技术
原文地址:https://www.cnblogs.com/saolv/p/10325016.html
时间: 2024-10-31 09:54:13