Python3.8 异常AttributeError module ‘time’ has no attribute ‘clock’

出现异常:

在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)

SQLAlchemy报错AttributeError module 'time' has no attribute 'clock'

File "F:\project-python-dev\todo-master\venv\lib\site-packages\sqlalchemy\util\compat.py", line 171, in <module>

    time_func = time.clock

AttributeError: module 'time' has no attribute 'clock'

更新SQLAlchemy版本

Flask-SQLAlchemy报错:AttributeError module 'time' has no attribute 'clock'

Traceback (most recent call last):

  File "F:/project-python-dev/todo-master/app.py", line 9, in <module>

    from flask_sqlalchemy import SQLAlchemy

  File "F:\project-python-dev\todo-master\venv\lib\site-packages\flask_sqlalchemy\__init__.py", line 35, in <module>

    _timer = time.clock

AttributeError: module 'time' has no attribute 'clock'

更新Flask-SQLAlchemy:

大T笔记所有文章均为本人原创,转载请您注明来源,并留下原文链接地址,是对我的尊重,也是对知识的尊重,谢谢!
大T笔记 » Python3.8 异常AttributeError module ‘time’ has no attribute ‘clock’

大T笔记-我的个人互联网创业和自由职业之路

关于我 我的百宝箱
大T笔记-专注个人互联网创业和自由职业