Python自学新手请教大神:

我想用Python的Class来做一个计时器, 将Class命名为Timer, 用start method 和 end method, t = timer, t.start(), t.end(),t.end() 停止计时器并将记录的时间到终端显示, 当计时器已经开始运行时t.start()给出error,当计时器计时器没有运行时t.end()给出error,timer可以设置显示小时,分钟或者秒, 而且显示最近一次的计时。Python版本为python 2.7, 谢谢大家了!

千万里不及你
浏览 44回答 1
1回答

GCT1015

import timedef start_sleep():time.sleep(3)if __name__ == '__main__':#The start timestart = time.clock()#A program which will run for 3 secondsstart_sleep()#The End timeend = time.clock()print("The function run time is : %.03f seconds" %(end-start))# End
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Python