I have unicode u\"{\'code1\':1,\'code2\':1}\"
and I want it in dictionary format.
I want it in {\'code1\':1,\'code2\':1}
format.
I
You can use built-in ast
package:
import ast
d = ast.literal_eval("{'code1':1,'code2':1}")
Help on function literal_eval in module ast:
literal_eval(node_or_string)
Safely evaluate an expression node or a string containing a Python expression. The string or node provided may only consist of the following Python literal structures: strings, numbers, tuples, lists, dicts, booleans, and None.