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

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()

 
发布了118 篇原创文章 · 获赞 17 · 访问量 7万+

猜你喜欢

转载自blog.csdn.net/one312/article/details/105458461