使用模块播放声音时出现错误“无法在引号内的字符串后指定额外字符。”

2024-05-20 01:52:13 发布

您现在位置:Python中文网/ 问答频道 /正文

基本上这是我的代码:

from playsound import playsound

playsound('C:\\Users\\arnavb\\Desktop\\Python\\Lecture1\\song.mp3')

我得到的错误是:

PS C:\Users\arnavb\Desktop\Python> & C:/Users/arnavb/AppData/Local/Programs/Python/Python39/python.exe c:/Users/arnavb/Desktop/Python/Lecture1/Practice_3.py

    Error 305 for command:
        open "C:\Users\arnavb\Desktop\Python\Lecture1\song.mp3"
    Cannot specify extra characters after a string enclosed in quotation marks.

    Error 263 for command:
        close "C:\Users\arnavb\Desktop\Python\Lecture1\song.mp3"
    The specified device is not open or is not recognized by MCI.
Failed to close the file: "C:\Users\arnavb\Desktop\Python\Lecture1\song.mp3"
Traceback (most recent call last):
  File "c:\Users\arnavb\Desktop\Python\Lecture1\Practice_3.py", line 2, in <module>
    playsound('C:\\Users\\arnavb\\Desktop\\Python\\Lecture1\\song.mp3')
  File "C:\Users\arnavb\AppData\Local\Programs\Python\Python39\lib\site-packages\playsound.py", line 72, in _playsoundWin
    winCommand(u'open {}'.format(sound))
  File "C:\Users\arnavb\AppData\Local\Programs\Python\Python39\lib\site-packages\playsound.py", line 64, in winCommand
    raise PlaysoundException(exceptionMessage)
playsound.PlaysoundException:
    Error 305 for command:
        open "C:\Users\arnavb\Desktop\Python\Lecture1\song.mp3"
    Cannot specify extra characters after a string enclosed in quotation marks.

Tags: inpysonglocalerroropenmp3users