以下是我收到的错误和我编写的代码。我知道有人问过类似的问题,但他们给出的解决方案与本案无关。我似乎无法弄清楚为什么会收到此属性错误。我正在运行 python 3.3 和 pygame。我使用的操作系统是ubuntu 12.10。我希望有人能找到这个问题的解决方案,这样我就可以继续进行物理模拟。
Traceback (most recent call last):
File "/media/lawton/D4B1-5B96/programming/Python/gamephysics.py", line 9, in <module>
screen = pygame.display.set_mode((width, height))
AttributeError: 'module' object has no attribute 'display'
import pygame
background_colour = (255,255,255)
(width, height) = (300, 200)
screen = pygame.display.set_mode((width, height))
pygame.display.set_caption('Tutorial 1')
screen.fill(background_colour)
pygame.display.flip()
running = True
while running:
for event in pygame.event.get():
if event.type == pygame.QUIT():
running = False
You are 影子 the pygame
与另一个图书馆pygame.py
文件,可能位于与gamephysics.py
.
打印出有问题的模块的文件路径:
import pygame
print('Path to pygame module:', pygame.__file__)
这将向您显示“恶意”模块所在的位置。找到它后,将其重命名为其他名称。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)