大佬求帮助
import time as tclass My:
#开始计时
def start(self):
self.start = t.localtime()
print('计时开始!')
#结束计时
def stop(self):
self.stop = t.localtime()
self._calc()
print('计时结束!')
print(self.promote)
#内部方法,计算时间
def _calc(self):
self.lasted = []
self.prompt = '总共运行了'
for index in range(6):
self.lasted.append(self.stop - self.start)
self.promote += str(self.lasted)
print(self.prompt)
这是代码
Traceback (most recent call last):
File "C:/Users/Lenovo/Desktop/计时器.py", line 3, in <module>
class My:
File "C:/Users/Lenovo/Desktop/计时器.py", line 14, in My
print(self.promote)
NameError: name 'self' is not defined
是哪里出了问题呢,应该怎么解决呢,求大佬帮忙解答一下
这个是打错了stop函数那里没有print 解决了,我把内部变量放外部调用了,打扰了大佬们
页:
[1]