鱼C论坛

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

[已解决]求问为什么报错

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

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

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

x
  1. import time
  2. class MyTimer():
  3.     def start(self):
  4.         self.start=time.localtime
  5.         print('计时开始!')
  6.     def stop(self):
  7.         self.stop = time.localtime
  8.         print('计时结束')
  9.         self.xiangjian()
  10.     def xiangjian(self):
  11.         self.jihe=[]
  12.         self.prom='总共运行了:'
  13.         for index in range(6):
  14.             self.jihe.append(self.stop[index] - self.start[index])
  15.             self.prom += str(self.jihe[index])

  16.         print(self.prom)
复制代码

为什么报错
  1. >>> ti=MyTimer()
  2. >>> ti.start()
  3. 计时开始!
  4. >>> ti.stop()
  5. 计时结束
  6. Traceback (most recent call last):
  7.   File "<pyshell#5>", line 1, in <module>
  8.     ti.stop()
  9.   File "C:\Users\Administrator\AppData\Local\Programs\Python\Python36\3R23.py", line 9, in stop
  10.     self.xiangjian()
  11.   File "C:\Users\Administrator\AppData\Local\Programs\Python\Python36\3R23.py", line 14, in xiangjian
  12.     self.jihe.append(self.stop[index] - self.start[index])
  13. TypeError: 'builtin_function_or_method' object is not subscriptable
  14. >>>
复制代码

TypeError:“builtin_function_or_method”对象不是可下载的
为什么
最佳答案
2018-1-5 17:08:54
self.start=time.localtime()
self.stop = time.localtime()
小甲鱼最新课程 -> https://ilovefishc.com
回复

使用道具 举报

发表于 2018-1-5 17:08:54 | 显示全部楼层    本楼为最佳答案   
self.start=time.localtime()
self.stop = time.localtime()
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

 楼主| 发表于 2018-1-6 13:49:10 | 显示全部楼层
冬雪雪冬 发表于 2018-1-5 17:08
self.start=time.localtime()
self.stop = time.localtime()

谢谢谢谢
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-3-5 11:10

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

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