在python中,“Music on or music off”。如果用户选择“Y”将播放音乐,如果用户选择“N”我不想播放音乐等。这是“if,else type thing? 谢谢!
from pygame import *
Y = input("Listen To Music While Test Y/N ")
if Y == "Y" or Y == "y":
print("Enjoy")
else:
print("Fine be that way")
mixer .init()
mixer.music.load("Sound.wav")
mixer.music.play(-1,0.0)
while mixer.music.get_busy():
time.Clock().tick(10)
答案 0 :(得分:1)
不需要评论。
import pygame
answer = input("Listen To Music While Test Y/N ")
answer = answer.lower()
if answer == "y":
print("Enjoy")
pygame.mixer.init()
pygame.mixer.music.load("Sound.wav")
pygame.mixer.music.play(-1,0.0)
while pygame.mixer.music.get_busy():
pygame.time.Clock().tick(10)
else:
print("Fine be that way")