装饰器
from functools import wraps
def decorate1(func):
"This is decorate1"
@wraps(func)
def wrapper(*args, **kwargs):
"This is wrapper func"
print('decorate1')
return func(*args, **kwargs)
return wrapper
def decorate2(func):
"This is decorate2"
@wraps(func)
def wrapper(*args, **kwargs):
print('decorate2')
return func(*args, **kwargs)
return wrapper
@decorate2
@decorate1
def test():
"This is a test"
pass
test()
print(test.__name__)
print(test.__doc__)