【发布时间】:2015-09-30 09:06:27
【问题描述】:
我的 Pygame 程序有问题。我需要帮助。 wav 文件与 python 文件位于同一目录中。 我在终端 Python3 中运行它:
import pygame.mixer
sounds = pygame.mixer
sounds.init()
def wait_finish(channel):
while channel.get_busy():
pass
asked = 0
true = 0
false = 0
choice = str(input("Push 1 for true, 2 for false, 0 to end"))
while choice != '0':
if choice == '1':
asked = asked + 1
true = true + 1
s = sounds.Sound("correct.wav")
wait_finish(s.play())
if choice == '2':
asked = asked + 1
false = false + 1
s = sounds.Sound("wrong.wav")
wait_finish(s.play())
choice = str(input("Push 1 for true, 2 for false, 0 to end"))
print ("you asked" +str(asked) + "questions")
print ("there were" +str(false) + "wrong answers")
print ("and" + str(true) + "correct answers")
它抛出- pygame.error:
无法打开文件'correct.wav'
【问题讨论】:
-
剪切并粘贴确切的错误
-
你有 `s =sounds.Sound("correct.wav")` 和
s = sounds.Sounds("wrong.wav"),这是正确的声音或声音 -
@user696 请确认Alex.S的建议你试过了吗?
-
在我在这里描述我的问题之前,我看到了 Alex.S 的解决方案。是的,感谢 Saxony 的 Rolf,我修正了 sound.sound() 的错误,但仍然无法正常工作。我已经阅读了网上的其他建议。我正在使用 Linux Xubuntu 和 python3。