【问题标题】:AttributeError: not found module 'time' has no attribute 'clock'AttributeError: not found module \'time\' has no attribute \'clock\'
【发布时间】:2022-08-04 20:57:41
【问题描述】:
Traceback (most recent call last):
  File \"D:\\Mata Kuliah\\Semester VI\\Bahan Sistem Tersebar\\concurrent_futures_pooling.py\", line 20, in <module>   
    start_time = time.clock()
AttributeError: module \'time\' has no attribute \'clock\'
  • 你是如何导入time 的? import time 还是 from time import time?你需要第一个。
  • 你需要time.time()
  • @Guy 这无关紧要,因为 Python 3 的 time 模块没有 clock

标签: python pandas matplotlib


【解决方案1】:

time 内置模块在 Python 3 中确实没有 clock() 导出。

您需要调整您的(显然与 Python 2 兼容的)代码以与 Python 3 兼容。

在 Python 2 中,time.clock() 通常用于高分辨率“秒表”计时。 Python 3.3+ 中的替换是time.perf_counter()

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2022-12-27
    • 2022-12-01
    • 2019-07-10
    • 2015-09-26
    • 2020-11-23
    • 2022-08-24
    • 2014-12-20
    • 2021-12-12
    相关资源
    最近更新 更多