how to change a string into dictionary

Daniel Urban urban.dani at gmail.com
Mon Aug 9 13:06:24 EDT 2010


> a = "{'a':'1','b':'2'}"
> how to change a into a dictionary ,says, a = {'a':'1','b':'2'}

See also the ast.literal_eval function:
http://docs.python.org/py3k/library/ast.html#ast.literal_eval


Daniel



More information about the Python-list mailing list