鱼C论坛

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

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

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

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

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

x
import time as t


class Mytimer:
        def __init__(self):
                self.time=t.localtime()
                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]))

        def start(self):
                self.begin=t.localtime()
                print('开始计时')
                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]))

        def pause(self):
                self.end=t.localtime()
                print('计时结束')
                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]))
                temp=[]
                def count(self):
                        nonlocal temp
                        for i in range(0,6):
                                result=self.end[i]-self.begin[i]
                                temp.append(result)        
                count(self)
                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-9-21 10:46

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

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