Creating a dictionary from a string

前端 未结 7 1981
轻奢々
轻奢々 2020-12-08 17:02

I have a string in the form of:

s = \'A - 13, B - 14, C - 29, M - 99\'

and so on (the length varies). What is the easiest way to create a d

7条回答
  •  情书的邮戳
    2020-12-08 17:16

    Those who came here with following problem :

    convert string a = '{"a":1,"b":2}' to dictionary object.

    you can simply use a = eval(a) to get a as object of dictionary from a string object.

提交回复
热议问题