python 字典形式的字符串转字典

>>> import ast
>>> aar='{"ab":1,"ac":2,"ad":3}'
>>> aaxx=ast.literal_eval(aar)
>>> aaxx
{'ab': 1, 'ac': 2, 'ad': 3}
>>> 
>>> aar='{"ab":1,"ac":2,"ad":3}'
>>> aayy=eval(aar)
>>> aayy
{'ab': 1, 'ac': 2, 'ad': 3}
>>> 

 

posted @ 2022-12-11 15:38  myrj  阅读(28)  评论(0编辑  收藏  举报