Why does 'time.clock()' raise an AttributeError in Python?
- 内容介绍
- 文章标签
- 相关推荐
本文共计171个文字,预计阅读时间需要1分钟。
在Python 3.8及以上版本中,`time.clock()` 函数已被弃用,因此会引发 `AttributeError`。你可以使用 `time.perf_counter()` 来替代它。以下是修改后的代码:
pythonstartTime=time.perf_counter()
startTime = time.clock()AttributeError: module 'time' has no attribute 'clock
python 报错!
AttributeError module 'time' has no attribute 'clock'
python3.8不支持clock了,替换成time.perf_counter()替换就可以了
若有帮助到您,欢迎点击推荐,您的支持是对我坚持最好的肯定(*^_^*)
你要保守你心,胜过保守一切。
作者:刘俊涛的博客
本文共计171个文字,预计阅读时间需要1分钟。
在Python 3.8及以上版本中,`time.clock()` 函数已被弃用,因此会引发 `AttributeError`。你可以使用 `time.perf_counter()` 来替代它。以下是修改后的代码:
pythonstartTime=time.perf_counter()
startTime = time.clock()AttributeError: module 'time' has no attribute 'clock
python 报错!
AttributeError module 'time' has no attribute 'clock'
python3.8不支持clock了,替换成time.perf_counter()替换就可以了
若有帮助到您,欢迎点击推荐,您的支持是对我坚持最好的肯定(*^_^*)
你要保守你心,胜过保守一切。
作者:刘俊涛的博客

