python基础---装饰器模式

时间:2021-11-16 18:42:35
def outer(fun):  #fun相当于是fun1方法
def wrapper(arg):
print "今天"
result = fun(arg)
print "天好"

return result
return wrapper

@outer
def fun1(arg):
print "fun1"+str(arg)
return 'return'

'''
@outer
def fun1(arg)
相当于是:
fun1 = def wrapper():
print "今天"
fun()
print "天好"
return wrapper
'''

print fun1(33)