【发布时间】:2018-04-02 12:19:31
【问题描述】:
我正在我的树莓派 3 上学习 python,所以我想我会尝试添加一些图形。我试图打开一个窗口来添加我的图形,但它会显示以下错误消息:
Traceback (most recent call last):
File "/home/pi/python_programmes/pygame1.py", line 1, in <module>
import pygame
File "/home/pi/python programmes/pygame.py", line 6, in <module>
AttributeError: 'module' object has no attribute 'init'
我输入的代码是:
import pygame
pygame.init()
size = [700, 500]
screen = pygame.display.set_mode(size)
pygame.display.set_caption("My game")
done = False
clock = pygame.time.Clock()
while done == False:
for event in pygame.event.get():
if event.type == pygame.QUIT:
done = True
clock.tick(20)
pygame.quit()
我删除了所有名为 pygame.py 的文件,但仍有一个名为 pygame.pyc 的文件
【问题讨论】:
-
@skrx 不是,因为我尝试了它在问题中所说的内容,并将其称为不是 pygame.py 的东西,但它仍然出现相同的错误消息
标签: python pygame raspberry-pi3