weixin_精慕门3117849
2018-12-26 23:42
t1=time.time()
r=f(*args,**kw)
t2=time.time()
if unit=='ms':
t=(t2-t1)*1000
elif unit=='s':
t=t2-t1
else:
print 'none'
print 'call %s() in %f%s'%(f.__name__,t,unit)
return r
我一开始写成
t1=time.time()
r=f(*args,**kw)
t2=time.time()
t=t2-t1
if unit=='ms':
return t*1000
elif unit=='s':
return t
else:
print 'none'
print 'call %s() in %f%s'%(f.__name__,t,unit)
return r
为什么第二种最后一句print并没有打印呢? 仅仅打印了f的结果。先写一个t=t2-t1为什么不可以??
已经return了 函数已经结束
你用的手机吧,用大点的例如平板,或者电脑显示器,分辨率高的显示的清。
在你执行if语句的时候,这段函数已经结束了,程序识别到return语句时,会跳出循环体
python进阶
255739 学习 · 2946 问题