python学习笔记之多个装饰器

#多个装饰器装饰一个函数
def wrapper1(func):
def inner1():
print('wrapper1 ,before func')
ret = func()
print('wrapper1 ,after func')
return ret
return inner1

def wrapper2(func):
def inner2():
print('wrapper2 ,before func')
ret = func()
print('wrapper2 ,after func')
return ret
return inner2

def wrapper3(func):
def inner3():
print('wrapper3 ,before func')
ret = func()
print('wrapper3 ,after func')
return ret
return inner3

@wrapper3
@wrapper2
@wrapper1
def f():
print('in f')
return '哈哈哈'
posted @ 2019-05-20 08:30  18软件工程五班陈星星  阅读(129)  评论(0编辑  收藏  举报