解决问题 AttributeError: module 'time' has no attribute 'clock' 解决思路 属性错误:模块'time'没有'clock'属性 解决方法 在Python 3.8及以后的版本中,time.clock()函数已被删除。该函数曾经返回处理器时间,这并不是实际经过的时间,而是当前进程使用的CPU时间。以后,我们可以使用time.perf_counter()函数来获取当前的CPU时间,或者使用time.process_time()函数来获取当前进程使用的CPU时间。import time start_time = time.perf_counter() # some code to measure execution time end_time = time.perf_counter() print("Execution time:", end_time - start_time) 将time.clock() 改为time.perf_counter 大功告成! |
|