if unit = 'ms':这句单独用语法出错了吗
import time
def performance(unit):
def printf(f):
def dota_time(*args,**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 dota_time
return printf
@performance('ms')
def factorial(n):
return reduce(lambda x,y: x*y, range(1, n+1))
print factorial(10)
为什么我的报错了 if unit = 'ms':说这句语法错误