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)