
音乐播放方式:
import pygame as py #!导入pygame
py.mixer.init() #!让音乐部分初始化
#!加载音乐
py.mixer.music.load("D:/roborobo/MC_dev/MCDemo/啵.wav")
#!加载后,播放音乐
py.mixer.music.play(-1) #! -1表示循环播放,啥都不写就放一次
while 1:
pass
样例:
import easygui as e
import pygame
import sys
import pygame
pygame.mixer.init() #!初始化
nums = 0
while True:
user_name = e.enterbox(msg='请输入密码',title='登陆')
if user_name == '0':
pygame.mixer.music.load('C:/Users/ningwang/Desktop/RoBotest/登录提示音.mp3')
pygame.mixer.music.play()
while 1:
click = e.msgbox(msg='积赛博功德,见机甲佛祖',image='木鱼.png',title='木鱼')
if click != '':
print('点击了木鱼')
else:
e.msgbox(msg='密码错误',title='登陆')
nums += 1
if nums == 3:
e.msgbox(msg='密码错误次数过多,程序退出',title='登陆')
sys.exit()