代码不知道哪里错了~帮忙解答
import time
def performance(unit):
def performance_decorator(f):
def wrapper(*arg, **kw):
t1 = time.time()
r = f(*args, **kw)
t2 = time.time()
if unit == 'ms':
t = (t2 - t1) * 1000
else:
t = (t2 - t1)
print('call %s() in %f %s' % (f.__name__, t, unit))
return r
return wrapper
return performance_dacorator
@performance('ms')
def factorial(n):
return reduce(lambda x,y: x*y, range(1, n+1))
print(factorial(10))