pythonpython-playsound

What to do with "Cannot specify extra characters after a string enclosed in quotation marks" error?


I have a piece of code that plays a sound using the playsound module but the file location gives an error:

import playsound

playsound.playsound('C:\\Users\\nc_ma\\Downloads\\Note1.mp3')

error:

Error 305 for command:
    open "C:\Users\nc_ma\Downloads\Note1.mp3"
Cannot specify extra characters after a string enclosed in quotation marks.

Solution

  • I had the same problem and I tried another way: I used os

    import os
    os.startfile('path\\file.filetype')
    

    and it started working for you:

    os.startfile('C:\\Users\\nc_ma\\Downloads\\Note1.mp3')
    

    or

    from playsound import playsound
    playsound('Path\\File Name.mp3')