首页 > 其他 > 详细

pyhton3 之 time模块实例小结

时间:2019-08-19 21:31:32      阅读:124      评论:0      收藏:0      [点我收藏+]

一、实例1:实现秒表:

 1 import time
 2 
 3 print(按下回车开始计时,按下 Ctrl + C 停止计时。)
 4 while True:
 5     try:
 6         input()  # 如果是 python 2.x 版本请使用 raw_input()
 7         starttime = time.time()
 8         print(开始)
 9         while True:
10             print(计时: , round(time.time() - starttime, 0), , end="\r")
11             time.sleep(1)
12     except KeyboardInterrupt:
13         print(结束)
14         endtime = time.time()
15         print(总共的时间为:, round(endtime - starttime, 2), secs)
16         break

 

pyhton3 之 time模块实例小结

原文:https://www.cnblogs.com/gengyufei/p/11379710.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!