#!/usr/bin/env python # -*- coding:utf-8 -*- # 作者: Apollo # 邮箱: 1986690272@qq.com # 博客: http://www.zgerji.online/ def wrapper1(func): # func = f def inner1(): print('wrapper1 ,before func') func() print('wrapper1 ,after func') return inner1 def wrapper2(func): # func = inner1 def inner2(): print('wrapper2 ,before func') func() print('wrapper2 ,after func') return inner2 @wrapper2 # f = wrapper2(f) 里面的f == inner1 外面的f = inner2 @wrapper1 # f = wrapper1(f) 返回inner1 f = inner1 def f(): print('in f') f() # inner2() # 详解图解文件:多个装饰器装饰一个函数.png