【发布时间】:2015-12-17 20:45:38
【问题描述】:
我刚刚下载了 Pygame,但遇到了错误:AttributeError: module 'pygame' has no attribute 'init'。我在stackoverflow上环顾四周,有人通过重命名文件来修复错误(我不知道该怎么做)。目录如下
Python -> Lib -> 站点包 ->pygame
让我困惑的部分是在 pygame 文件夹中
pygame > Include, Lib
Include > pygame > (many hh files)
Lib > SitePackages > pygame > init (I know that it has the attribute init)
既然有 '3' pygame 文件夹,这是否会导致我的程序出错?
import pygame, sys
pygame.init()
DISPLAYSURF = pygame.display.set_mode((400, 300))
pygame.display.set_caption('Hello World!')
while True: # main game loop
for event in pygame.event.get():
if event.type == QUIT:
pygame.quit()
sys.exit()
pygame.display.update()
【问题讨论】: