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}

posted @ 2020-12-09 20:37  巴黎爱工作  阅读(398)  评论(0编辑  收藏  举报