马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
import time as t
class MyTimer():
def start(self):
self.start = t.localtime()
print("计时开始")
def stop(self):
self.stop = t.localtime()
print("计时结束")
self._calc
def _calc(self):
self.leasted = []
for index in range(6):
self.leasted.append(self.stop[index] - self.start[index])
self.info = "总共运行了" + str(self.leasted)
print(self.info)
报错>>> t = MyTimer()
>>> t.start
<bound method MyTimer.start of <__main__.MyTimer object at 0x000001EDCBADB4A8>>
>>> t.start()
Traceback (most recent call last):
File "<pyshell#8>", line 1, in <module>
t.start()
File "C:\Users\945\Desktop\MyTimer.py", line 5, in start
self.start = t.localtime()
AttributeError: 'MyTimer' object has no attribute 'localtime'
>>>
请问是不是我没有安装对应的包,我这个python下过来确实好久了没动了。 |