python
import time
def performance(f):
def fn(x):
t1 = time.time()
f(x)
t2 = time.time()
return t2 - t1
return fn
@performance
def factorial(n):
return reduce(lambda x,y: x*y, range(1, n+1))
print factorial(10)
这里为什么输出错误呢
import time
def performance(f):
def fn(x):
t1 = time.time()
f(x)
t2 = time.time()
return t2 - t1
return fn
@performance
def factorial(n):
return reduce(lambda x,y: x*y, range(1, n+1))
print factorial(10)
这里为什么输出错误呢
2019-10-15
举报