python 报错 AttributeError: module ‘time‘ has no attribute ‘clock 解决方法
源码如下:
#引入所需要的时间库
import datetime
import time
#程序计时器,启动计时器
start = time.clock()
#中间是放置需要测试运行时间的程序代码
#计算启动时间和结束时间的时间差
end = time.clock()
print('运行时间 : %s 秒'%(end-start))
报错 AttributeError module ‘time’ has no attribute ‘clock’
解决方法:python3.8不支持 clock 了,用 time.perf_counter() 替换就可以了
还没有评论,来说两句吧...