import time as t
class Mytimer():
def start(self):
self.start = t.localtime()
print("计时开始")
def stop(self):
self.start = t.localtime()
self._calc()
print("计时结束")
def __calc(self):
self.lasted = []
self.prompt = "总共运行了"
for index in range(6):
self.lasted.append(self.stop[index] - slef.start[index])
self.prompt += str(self.lasted[index])
print(self.prompt)
然后报错就是这样
然后可以全代码详解吗
你这用的一个下划线还是两个下划线,要一致。这代码就是计算执行for循环用的时间吧