DEV Community πŸ‘©β€πŸ’»πŸ‘¨β€πŸ’»

Max Angelo Dapitilla Perin
Max Angelo Dapitilla Perin

Posted on

Answer: replace double quotes with '\"' in python

Try this:

print l.replace('"','\\"')

'\"' doesn't mean anything special to Python, so you needn't to add \ before ",if you run

print l.replace('\"', '\\"'),you will get a single backslash too.

Actually what you are seeing is the representation of the string, it's added by repr() method.Python represents…

Top comments (0)

πŸ” If you came here from Google, why not take a look at some of our top posts?