不用内部函数怎么样?
import time
def performance(f):
print '=========call '+ f.__name__ +'() in:'+time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())
return f
@performance
def factorial(n):
return reduce(lambda x,y: x*y, range(1, n+1))
print factorial(10)
import time
def performance(f):
print '=========call '+ f.__name__ +'() in:'+time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())
return f
@performance
def factorial(n):
return reduce(lambda x,y: x*y, range(1, n+1))
print factorial(10)
2019-12-30
举报