Python 报错:module 'pygame.time' has no attribute 'clock'

系统管理员 2023-07-24 13:06 68阅读 0赞

0.代码:







fpsclock = pygame.time.clock()

1.报错如下:







/home/wdh/anaconda3/envs/tanchishe9/bin/python /home/wdh/PycharmProjects/tanchishe9/tanchishe.py
pygame 1.9.6
Hello from the pygame community. https://www.pygame.org/contribute.html
Traceback (most recent call last):
  File “/home/wdh/PycharmProjects/tanchishe9/tanchishe.py”, line 117, in <module>
    main()
  File “/home/wdh/PycharmProjects/tanchishe9/tanchishe.py”, line 28, in main
    fpsclock = pygame.time.clock()
AttributeError: module ‘pygame.time’ has no attribute ‘clock’

Process finished with exit code 1

2.错误原因:属性或者函数名称写错,注意大小写。这里的错误是clock() 的首字符应该是大写C

3.正确代码:










fpsclock = pygame.time.Clock()

 

发表评论

表情:
评论列表 (有 0 条评论,68人围观)

还没有评论,来说两句吧...

相关阅读