|
|
发表于 2018-11-19 16:57:28
|
显示全部楼层
本帖最后由 喜欢吃菠菜 于 2018-11-19 16:59 编辑
这个代码没有问题,就是变量start打成strat,还有私有函数_calc打成_calc_ 多了一个下标。
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])
print(self.prompt)
>>> a=Mytimer()
>>> a.start()
计时看开始...
>>> a.stop()
总共运行了0000010
计时结束... |
|