出現異常:
在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