|
|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
import time as t
class Mytimer():
#开始计时
def start(self):
self.start = t.localtime()
print('计时开始.....')
#停止计时
def stop(self):
self.stop = t.localtime()
self.__calc()
print('计时结束!...')
#内部方法,计算运行时间
def __calc(self):
self.lasted = []
self.prompt = '总共运行了'
for index in range(6):
self.lasted.append(self.stop[index] - self.start[index])
self.prompt += str(self.lasted[index] - self.start[index])
print(self.prompt)
a = Mytimer()
>>> a.start()
计时开始.....
>>> a.stop()
总共运行了-2018
总共运行了-2018-11
总共运行了-2018-11-7
总共运行了-2018-11-7-20
总共运行了-2018-11-7-20-20
总共运行了-2018-11-7-20-20-18
计时结束!... |
|