python3.9中module ‘time‘ has no attribute ‘clock‘

报错如下:module ‘time’ has no attribute ‘clock’
在这里插入图片描述

原因:

time.clock()已经在新的版本中移除了。在Python3.8中更新了。
“The function time.clock() has been removed, after having been deprecated since Python 3.3: use time.perf_counter() or time.process_time() instead, depending on your requirements, to have well-defined behavior. (Contributed by Matthias Bussonnier in bpo-36895.)”

解决方案:

time.clock()改为time.perf_counter()或者time.process_time()

python3.8中module ‘time’ has no attribute ‘clock’

猜你喜欢

转载自blog.csdn.net/weixin_43798960/article/details/111694230
今日推荐