鱼C论坛

 找回密码
 立即注册
查看: 3214|回复: 2

[技术交流] 今天刚看了计时器,就写了一个计时器

[复制链接]
发表于 2019-1-13 20:40:56 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能^_^

您需要 登录 才可以下载或查看,没有账号?立即注册

x
  1. import time as t


  2. class Mytimer:
  3.         def __init__(self):
  4.                 self.time=t.localtime()
  5.                 print('当前时间是%d-%d-%d %d:%d:%d'%(self.time[0],self.time[1],self.time[2],self.time[3],self.time[4],self.time[5]))

  6.         def start(self):
  7.                 self.begin=t.localtime()
  8.                 print('开始计时')
  9.                 print('当前时间是%d-%d-%d %d:%d:%d'%(self.begin[0],self.begin[1],self.begin[2],self.begin[3],self.begin[4],self.begin[5]))

  10.         def pause(self):
  11.                 self.end=t.localtime()
  12.                 print('计时结束')
  13.                 print('当前时间是%d-%d-%d %d:%d:%d'%(self.end[0],self.end[1],self.end[2],self.end[3],self.end[4],self.end[5]))
  14.                 temp=[]
  15.                 def count(self):
  16.                         nonlocal temp
  17.                         for i in range(0,6):
  18.                                 result=self.end[i]-self.begin[i]
  19.                                 temp.append(result)       
  20.                 count(self)
  21.                 print('所经历的时间是:%d秒'%(temp[3]*3600+temp[4]*60+temp[5]))



复制代码
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复

使用道具 举报

发表于 2022-11-29 19:23:51 | 显示全部楼层
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复

使用道具 举报

发表于 2023-9-29 11:06:52 | 显示全部楼层
学习了学习了
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

GMT+8, 2024-5-6 10:48

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表