出现异常:
在pycharm中加Python3.8环境,调用time.clock出异常:AttributeError module ‘time’ has no attribute ‘clock’
经过度娘,其原因:
Python3.8不再支持time.clock,但在调用时依然包含该方法;
有效处理:
用time.perf_counter()替换
import time
tis1 =time.perf_counter()
print("等待5秒......")
time.sleep(5)
tis2=time.perf_counter()
print(tis2-tis1)
# 等待5秒......
# 4.999518311
原文链接:https://blog.csdn.net/jt_121217/article/details/104914923