python_装饰器
def debug(func):
def wrapper():
print("这是一个装饰器")
return func()
return wrapper
@debug
def say():
print("hello")
say()
返回:
这是一个装饰器
hello
python_装饰器
def debug(func):
def wrapper():
print("这是一个装饰器")
return func()
return wrapper
@debug
def say():
print("hello")
say()
返回:
这是一个装饰器
hello