python中将字符串转为字典类型
str_info = '{"name": "test", "age": 18}' dict_info = eval(str_info) print("string info type is -->: %s" % (type(str_info))) print("dict info type is -->: %s" % (type(dict_info))) print(dict_info)
string info type is -->: <class 'str'>
dict info type is -->: <class 'dict'>
{'name': 'test', 'age': 18}
------------------------- A little Progress a day makes you a big success... ----------------------------