例子是多个修饰符参数的例子
def decorator_factory(enter_message, exit_message):
# We're going to return this decorator
def simple_decorator(f):
def wrapper(*args, **kwds):
print enter_message
f(*args, **kwds)
print exit_message
return wrapper
return simple_decorator
@decorator_factory("Start", "End")
def hello(username,name):
print "Hello World"
print username,name
hello('ddddddddddddddd','ffff')
运行结果