Python convert string object into dictionary

前端 未结 4 1337
太阳男子
太阳男子 2021-01-14 21:48

I have been working to build a complex data structure which would return a dictionary. Currently that class return string object of the form

{
   cset : x,           


        
4条回答
  •  悲哀的现实
    2021-01-14 22:23

    Is that the actual data format? Do you have any flexibility?

    It's very nearly JSON, which is a standard data format for which Python has native libraries for reading and writing (serialising and deserialising). However, to make it valid JSON both the keys and values would need to be surrounded by quotes:

    "cset" : "x",
    "b1"   : "y"
    

    and so on.

提交回复
热议问题