Discuss / Python / 1
def log(func):
    def wrapper(*args,**kw):
        print('call bigin %s():'%func.__name__)
        func(*args,**kw)
        print('call end %s():'%func.__name__)
    return wrapper
@log
def now():
    print('2016')
now()

结果: call bigin now(): 2016 call end now():

跟我一开始写的一样,其实有问题


  • 1

Reply