概述
# 来自jb51.cc
@deco1(deco_arg)
@deco2
def func(): pass
# 来自jb51.cc
func = deco1(deco_arg)(deco2(func))
# 来自jb51.cc
# -*-coding:utf-8 -*-
def decorator(str):
print str
def retfn(fn):
def retfn(*arg):
print '已装饰' # 装饰
return fn(*arg) # 调用原始函数
return retfn
return retfn
@decorator("实例化装饰器")
def test(str0,str1):
print str0,str1
test('Hello','world');
总结
以上是编程之家为你收集整理的Python的装饰器功能实例全部内容,希望文章能够帮你解决Python的装饰器功能实例所遇到的程序开发问题。
如果您也喜欢它,动动您的小指点个赞吧