我决定使用playsound()
在我的程序中添加背景声音。但是,当我使用 playsound 运行程序时,实际游戏在歌曲完成之前不会加载:
from playsound import playsound
#type 'pip install playsound' in command prompt to install library
import random
playsound('audio.mp3')
while True:
min = 1
max = 6
roll_again = "yes"
while roll_again == "yes" or roll_again == "y":
print("Rolling the dices...")
print("The values are....")
print(random.randint(min, max))
print(random.randint(min, max))
roll_again = raw_input("Roll the dices again?")
通常我希望在加载和播放骰子游戏时在后台播放声音,但它不是这样工作的。