第六行的t2后面的()忘了写,报错内容是指向第10行(unsupported operand type(s) for -: 'builtin_function_or_method' and 'float')
import time
def performance(f):
def fn(*args,**kw):
t1=time.time()
r=f(*args,**kw)
t2=time.time()
print 'call %s() in %f s'%(f.__name__,(t2-t1))
return r
return fn
@performance
def factorial(n):
return reduce(lambda x,y: x*y, range(1, n+1))
print factorial(10)