摘要:
多个装饰器 多个装饰器时,装饰器的执行顺序是由近到远,调用f1()后的执行顺序是由远到近 def test(func): print(' test ') def test2(): print(' test2 ') func() #指向test3 return test2 def test1(func 阅读全文
posted @ 2022-04-16 22:34
风中的琥珀
阅读(96)
评论(0)
推荐(0)
摘要:
装饰器 装饰器的原理就是闭包,调用方式不变,装饰器是在调用方法前进行的 def test(func): print(' func ') def test2(): print(' test2这里是扩展功能 ') func() return test2 @test def test1(): print( 阅读全文
posted @ 2022-04-16 21:20
风中的琥珀
阅读(25)
评论(0)
推荐(0)
摘要:
闭包 闭包的的用途可以在不修改原代码的情况下对其添加扩展功能 def test(func): print(' func ') def test2(): print(' test2这里是扩展功能 ') func() return test2 def test1(): print(' test1 ') 阅读全文
posted @ 2022-04-16 21:03
风中的琥珀
阅读(26)
评论(0)
推荐(0)