python - 错误“不能在用引号括起来的字符串后指定额外的字符。” 在使用模块 Playsound 时
问题描述
所以基本上这是我的代码:
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.
解决方案
请按照以下步骤操作:
pip uninstall playsound
pip install playsound==1.2.2
推荐阅读
- system-verilog - systemverilog 参数传递值如何工作?
- java - 为什么在我的 DataFrame 中找到最大数字会产生 0?
- ios - 如何获得蓝牙扬声器的音频延迟
- elasticsearch - 运行本地主机时如何解决 kibana 错误请求问题
- angular - 如何等待服务调用完成调用,一旦成功,在 Angular 2 中再次调用相同的服务
- java - 为什么要向 hashCode() 添加一个常量?
- format - 格式化(重新包装)Markdown 文档以遵守给定的线宽
- dart - 基于流数据的小部件操作
- amazon-web-services - AWS Sagemaker:可以修改现有的 train_image 演示吗?
- label - GtkLabel 不使用属性 visible = false 隐藏