01 使用playsound库
from playsound import playsound
playsound('xx.mp3')
注意, 安装模块后并不能直接执行播放, 需要修改代码
进入到代码后 搜索定位到这个函数中winCommand
# def winCommand 方法下
- command = ' '.join(command).decode('utf-16')
#改成这样
+ command = ' '.join(command)
exceptionMessage = ('\n Error ' + str(errorCode) + ' for command:'
- '\n ' + command.decode('utf-16') +
+ '\n ' + command +
'\n ' + errorBuffer.raw.decode('utf-16').rstrip('\0'))
02 使用pygame库
from pygame import mixer
import time
mixer.init()
mixer.music.load('xx.mp3')
mixer.music.play()
time.sleep(5)
mixer.music.stop()
03 打开系统自带播放器,然后播放MP3,弹窗麻烦复杂
import os
os.system('xx.mp3')