能够赋值给一个变量
能够在其他函数里定义
所以装潢器也是一样,这个例子中自定义了两个装潢器,然后在test()函数上添加了两个装潢器,运转效果一般。
#!/usr/bin/env python #coding:utf-8 def decorator1(func): def wrapper(): print 'hello python 之前' func() return wrapper def decorator2(func): def wrapper(): func() print 'hello python 以后' return wrapper @decorator1 @decorator2 def test(): print 'hello python!' test()
运转效果:
hello python 之前 hello python! hello python 以后
以上就是Python中如安在一个函数中到场多个装潢器的细致内容,更多请关注ki4网别的相干文章!