python核心编程笔记3--装饰器
def test2(func): def inner(): print 'new one!' func() print 'new two!' return inner @test2 def test1(): print 'old func!' test1()
在不修改原函数的基础上,又需要给函数增加功能的情况下,就可以使用装饰器
posted on 2018-04-12 16:25 theslowman 阅读(154) 评论(0) 编辑 收藏 举报
def test2(func): def inner(): print 'new one!' func() print 'new two!' return inner @test2 def test1(): print 'old func!' test1()
在不修改原函数的基础上,又需要给函数增加功能的情况下,就可以使用装饰器
posted on 2018-04-12 16:25 theslowman 阅读(154) 评论(0) 编辑 收藏 举报