|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
import time as t
class 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[index] - self.start[index])
self.promote += str(self.lasted[index])
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
是哪里出了问题呢,应该怎么解决呢,求大佬帮忙解答一下
|
|