Ask coding questions

← Back to all posts
help with syntax
MaxitoPlayer (4)

yup there was some so called syntax but if you go in the top right corner there is no bugs i was trying to play an audio file in python but somehow i got this

Answered by 19ecal (230) [earned 5 cycles]
View Answer
Comments
hotnewtop
19ecal (230)

You can either escape the backslashes with \\, or use a r-string (raw string), in which a backslash is just a backslash, like this

path=r"C:\Users\User\Documents"

This is especially useful for file paths on Windows, although forward slashes generally work fine in most cases too.

MaxitoPlayer (4)

@19ecal DUDE I COPIED THE PATH I AM NOT USING A DIFFERENT SYSTEM YOU KNOW WHAT HELP ME HERE ON REPL.IT

MaxitoPlayer (4)

NOPE THIS TOO HARD

MaxitoPlayer (4)

still did not work xd

Coder100 (17087)

Use a raw string:

f_name = r"C:\Users\fuzzy\..."

python has special annotations for the backslash.

OldWizard209 (1116)

actually @MaxitoPlayer change the \ to / and remove the C:

RYANTADIPARTHI (6008)

when using \ backslashes, you need two of them. Since they have special jobs in python. So use two of them \\.

SixBeeps (5061)

The backslashes need to be escaped, so just replace all instances of \ in the file path with \\