鱼C论坛

 找回密码
 立即注册
查看: 2144|回复: 2

求各位大神看看我是不是没有装对应的包

[复制链接]
发表于 2019-5-17 16:54:47 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能^_^

您需要 登录 才可以下载或查看,没有账号?立即注册

x
  1. import time as t

  2. class MyTimer():
  3.     def start(self):
  4.         self.start = t.localtime()
  5.         print("计时开始")

  6.     def stop(self):
  7.         self.stop = t.localtime()
  8.         print("计时结束")
  9.         self._calc
  10.     def _calc(self):
  11.         self.leasted = []
  12.         for index in range(6):
  13.             self.leasted.append(self.stop[index] - self.start[index])
  14.         self.info = "总共运行了" + str(self.leasted)
  15.         print(self.info)
  16.             
复制代码

            
报错
  1. >>> t = MyTimer()
  2. >>> t.start
  3. <bound method MyTimer.start of <__main__.MyTimer object at 0x000001EDCBADB4A8>>
  4. >>> t.start()
  5. Traceback (most recent call last):
  6.   File "<pyshell#8>", line 1, in <module>
  7.     t.start()
  8.   File "C:\Users\945\Desktop\MyTimer.py", line 5, in start
  9.     self.start = t.localtime()
  10. AttributeError: 'MyTimer' object has no attribute 'localtime'
  11. >>>
复制代码

请问是不是我没有安装对应的包,我这个python下过来确实好久了没动了。
小甲鱼最新课程 -> https://ilovefishc.com
回复

使用道具 举报

发表于 2019-5-17 17:07:12 | 显示全部楼层
你的模块叫做t,实例化对象也叫t,被覆盖了
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

 楼主| 发表于 2019-5-17 17:23:12 | 显示全部楼层
冬雪雪冬 发表于 2019-5-17 17:07
你的模块叫做t,实例化对象也叫t,被覆盖了

哈哈哈好的我知道了,我下次注意
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

GMT+8, 2025-5-16 22:17

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表