|  | 
 
| 
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]))
 | 
 |