Skip to content
KerwinKoo edited this page Dec 26, 2015 · 1 revision

python 将一个字符串(string)转为字典(dict)

>>> a = "{'a': 'hi', 'b': 'there'}"
>>> b = eval(a)
>>> b
{'a': 'hi', 'b': 'there'}
>>> exec ("c=" + a)
>>> c
{'a': 'hi', 'b': 'there'}
>>>

[[TOC]]

Clone this wiki locally