python 装饰器
#!/usr/bin/env pythondef deco(func1): #define a decorate function deco
def wrapper():
print"Hello Python!"
func()
print"I am Profero!"
return wrapper
@deco #use @deco call
def func2(): #define func2
print"What's your name? "
func2 #call func2
# The result:
Hello Python!
What's your name?
I am Profero!
页:
[1]