python中有一个内置函数eval
字符串为"{'A':123,'B':456,'C':789}"
s = "{'A':123,'B':456,'C':789}"
s_dic = eval(s)
s_dic
{'A':123,'B':456,'C':789}
s_dic的类型为dict,转换完成
python中有一个内置函数eval
字符串为"{'A':123,'B':456,'C':789}"
s = "{'A':123,'B':456,'C':789}"
s_dic = eval(s)
s_dic
{'A':123,'B':456,'C':789}
s_dic的类型为dict,转换完成
转载于:https://www.cnblogs.com/lihongda/p/9203613.html