Skip to content Skip to sidebar Skip to footer

Replace '\"' With " In Python Files

I am trying to read line and then replacing ''' this with ''' .Is there any issue my code .It is getting executed but not replacing those two characters: # Read in the file with op

Solution 1:

I'm not sure if I understand exactly what you're asking. What I understood is you want to replace \" with ".

In which case, you would be missing another backlash as backslash itself is a special character which you need to escape using \

withopen('filename', 'r') as file:
    filedata = file.read()
    filedata = filedata.replace('\\"', '"')

Post a Comment for "Replace '\"' With " In Python Files"