Convert unicode string dictionary into dictionary in python

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.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)