>>> sample = "hello'world"
>>> print sample
hello'world
>>> print sample.replace("'","\'")
hello'world
In my web app I need to store my python string with all single quotes escaped for manipulation later in the client browsers javascript. Trouble is python uses the same backslash escape notation so the replace operation as detailed above has no effect.
Hopefully there is a simple workaround?