def metric(fn): @functools.wraps(fn) def wrapper(args, **kw): t=time.asctime() res = fn(args, **kw) print('%s executed in %s' % (fn.name, t)) return res return wrapper
怎么做到只执行一次就返回执行消耗的时间?
Sign in to make a reply
红莲爆雷刃
def metric(fn): @functools.wraps(fn) def wrapper(args, **kw): t=time.asctime() res = fn(args, **kw) print('%s executed in %s' % (fn.name, t)) return res return wrapper
怎么做到只执行一次就返回执行消耗的时间?