Python pygame,加载.wav文件内存错误
我在Python pygame,加载.wav文件内存错误,python,pygame,Python,Pygame,我在conf.py文件中编写了代码 env_sound = pygame.mixer.Sound('resources/sound/env.wav') 在game.py文件中,我只是import conf env_sound = conf.env_sound 错误是 File "/path/game.py", line 8, in <module> import conf File "/path/conf.py", line 45, in <module>
conf.py
文件中编写了代码
env_sound = pygame.mixer.Sound('resources/sound/env.wav')
在game.py
文件中,我只是import conf
env_sound = conf.env_sound
错误是
File "/path/game.py", line 8, in <module>
import conf
File "/path/conf.py", line 45, in <module>
env_sound = pygame.mixer.Sound('resources/sound/env.wav')
MemoryError
文件“/path/game.py”,第8行,在
导入配置
文件“/path/conf.py”,第45行,在
env_sound=pygame.mixer.sound('resources/sound/env.wav'))
记忆者
game.py
和conf.py
在同一个目录中
env.wav
的大小约为511KB,我认为这不会导致内存错误
有什么问题吗?您需要初始化
pygame.mixer
使其工作。因此,大致如下:
#add this somewhere before env_sound = pygame.mixer.Sound('resources/sound/env.wav')
pygame.mixer.init(frequency=22050, size=-16, channels=2, buffer=4096)
阅读以获得进一步的参考。您需要初始化
pygame.mixer
以使其工作。因此,大致如下:
#add this somewhere before env_sound = pygame.mixer.Sound('resources/sound/env.wav')
pygame.mixer.init(frequency=22050, size=-16, channels=2, buffer=4096)
请阅读以下内容以供进一步参考