I'm trying to escape quote marks in Python, but my intended plan does not work:
>>> s = 'Hi "there"'
>>> s.replace('"', '\"')
'Hi "there"'
>>> s.replace('"', '\\"')
'Hi \\"there\\"'
What is the proper way to single-escape quotes within a string (e.g. make 'Hi \"there\"'
)?