python 装饰器
Posted qmzp
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了python 装饰器相关的知识,希望对你有一定的参考价值。
from _ctypes_test import func def deco1(arg): def mid_deco1(function): def new_func(): print ("deco1 > new_function : arg=%s" %(arg)) return function() return new_func return mid_deco1 @deco1("abc") def function1(): print "function1" def deco2(arg): def mid_deco2(function): def new_func(a): print ("deco2 > new_function : arg=%s" %(arg)) return function(a) return new_func return mid_deco2 @deco1("abc") def function2(a): print "function2" if "__name__" == "__main__": function1() function2()
以上是关于python 装饰器的主要内容,如果未能解决你的问题,请参考以下文章