我刚刚下载了 Pygame,但遇到了错误: AttributeError: module 'pygame' has no attribute 'init'.我在 stackoverflow 上四处查看,有人通过重命名文件修复了错误(我不知道该怎么做)。目录如下
Python -> Lib -> site-packages ->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()
只需将文件重命名为pygame.py
to myTestGame.py
例如;因为您在使用时导入相同的文件import pygame
!
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)