import pygame, time
from pygame.locals import *
soundObj = pygame.mixer.Sound('beeps.wav')
soundObj.play()
time.sleep(1) # wait and let the sound play for 1 second
soundObj.stop()
它抛出这个错误:
Traceback (most recent call last):
File "C:/Users/Jauhar/Desktop/Python/sounds.py", line 4, in <module>
soundObj = pygame.mixer.Sound('beeps.wav')
pygame.error: Unable to open file 'beeps.wav'
beeps.wav 文件保存在与代码所在的 python 文件相同的目录中。
我不明白为什么它不起作用!