You should be using the json
module. json.dumps(string)
. It can also serialize other python data types.
import json
>>> s="my string with "double quotes" blablabla"
>>> json.dumps(s)
<<< '"my string with \\"double quotes\\" blablabla"'
You should be using the json
module. json.dumps(string)
. It can also serialize other python data types.
import json
>>> s="my string with "double quotes" blablabla"
>>> json.dumps(s)
<<< '"my string with \\"double quotes\\" blablabla"'