[英]Music Y or Music N
In python, "Music on or music off" .在 python 中,“打开音乐或关闭音乐”。 If user selects "Y" music will play, If user selects "N" I don't want music to play etc. Is this a "if, else type thing? Thanks!
如果用户选择“Y”音乐将播放,如果用户选择“N”我不想播放音乐等等。这是一个“if, else type”吗?谢谢!
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)
It doesn't need comment.它不需要评论。
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")
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.