Python 启动flask报错:AttributeError: module ‘time‘ has no attribute ‘clock‘

阅读 81

2022-11-09


Python 启动flask报错:AttributeError: module ‘time’ has no attribute ‘clock’

问题描述——AttributeError: module ‘time’ has no attribute ‘clock’

python 使用 下面命令启动flask项目的时候报错:

python manager.py runserver -h 0.0.0.0 -p 8080

Python 启动flask报错:AttributeError: module ‘time‘ has no attribute ‘clock‘_flask

问题原因

错误分析:在python3.8中,time模块下不支持clock,改成time.perf_counter()即可解决错误。
改后代码是这样的:

解决方法

Python 启动flask报错:AttributeError: module ‘time‘ has no attribute ‘clock‘_解决方法_02

我这么用的是python3.8环境,所以需要改

Python 启动flask报错:AttributeError: module ‘time‘ has no attribute ‘clock‘_python_03

改成这样就可以了:

Python 启动flask报错:AttributeError: module ‘time‘ has no attribute ‘clock‘_后端_04

重新运行项目:

Python 启动flask报错:AttributeError: module ‘time‘ has no attribute ‘clock‘_解决方法_05

问题解决


精彩评论(0)

0 0 举报