python converts escaped strings
Sometimes we may get the following string:
Python code
>>> a = '{\"name\":\"michael\" }'
>>> print a
{"name":"michael"}
So how to convert it into a dictionary?
You can use the following method:
Python code
>>> type(json.loads('"' + a + '"'))
> ;>> type(json.loads(json.loads('"' + a + '"')))
The first time json.loads is the " Such a string is converted into "(only one double quote), and then converted into a dictionary for the second time. Remember not to forget to add the double quotes in front.