weixin_44511694 2021-04-16 11:32 采纳率: 100%
浏览 858
已采纳

'time' has no attribute 'pefr_counter',是什么问题?

程序如下:

#TextProBarV3.py
import time
scale = 50
print("执行开始".center(scale//2,"-"))
start =time.perf_counter()
for i in range(scale+1):
      a = "*"*i
      b = "."*(scale-i)
      c = (i/scale)*100
      dur = time.pefr_counter()-start
      print("\r{:……3.0f}%[{}->{}]s".format(c,a,b,dur),end='')
      time.sleep(0.1)
print("\n"+"执行结束".center(scale//2,'-'))

执行后,出现:

File "C:/Users/duoduo520/Documents/TextProBarV4py.py", line 10, in <module>
    dur = time.pefr_counter()-start
AttributeError: module 'time' has no attribute 'pefr_counter',这是什么问题?

用的是Python 3.9.0 shell

  • 写回答

3条回答 默认 最新

  • 关注

    time' has no attribute 'pefr_counter,就是time这个对象没有pefr_counter这个方法,应该是写错了哦,改为perf_counter就可以了。

    这行 dur = time.pefr_counter()-start改为

     dur = time.perf_counter()-start

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

问题事件

  • 已采纳回答 7月13日

悬赏问题

  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?
  • ¥15 c++头文件不能识别CDialog