所以我正在使用输入和 if 语句制作一个基于文本的 python 文件。但是如何在输入加载时播放 mp3 文件?我正在使用 Ubuntu 顺便说一句
我已经尝试过 pyglet、winsound、os 但它们都不起作用我尝试过 pygame 但它在加载输入时不播放文件
print("Welcome user")
name = input("Client name: ")
gender = input("Mr or Miss: ")
age = input("Client age: ")
room = input("Room: ")
sure = input("""All done!!!
Press any key to show the view!""")
welcome = f"""Welcome to room {room} {gender}. {name}!
Have a nice stay"""
if sure == "a":
print(welcome)
else:
print(welcome)
Os - "Module os has no startfile member"
pyglet - Doesnt import
winsound - Doesn't play the file
播放 mp3 文件的唯一成功尝试是当我使用 pygame 时,但即使那样它也不会同时加载输入无论如何,这是代码:
import pygame
import time
pygame.init()
pygame.mixer.music.load("elevmusic.mp3")
pygame.mixer.music.play()
time.sleep(10)
print("Welcome user")
name = input("Client name: ")
gender = input("Mr or Miss: ")
age = input("Client age: ")
room = input("Room: ")
sure = input("""All done!!!
Press any key to show the view!""")
welcome = f"""Welcome to room {room} {gender}. {name}!
Have a nice stay"""
if sure == "a":
print(welcome)
else:
print(welcome)