def makeBold(func):
def wrapper(*args, **kwargs):
return "" + func() + ""
return wrapper
def makeItail(func):
def wrapper(*args, **kwargs):
return "" + func() + ""
return wrapper
@makeItail
def test1():
return "hello world"
@makeBold
def test2():
return "hello world"
@makeBold
@makeItail
def test3():
return "hello world"
print(test1())
print(test2())
print(test3())
2. 输出结果
C:\Users\HuJun\PycharmProjects\pythonProject\venv\Scripts\python.exe C:/Users/HuJun/PycharmProjects/pythonProject/daily_tesy/嵌套装饰器.py
<i>hello world<i>
<b>hello world<b>
<b><i>hello world<i><b>
Process finished with exit code 0
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)