Python converts a string to the dictionary dict

  • 2020-04-02 09:47:39
  • OfStack


JSON Convert to dictionary: 
dictinfo = simplejson.loads(json_str)  The output dict type 
 The dictionary to JSON Transformation: 
jsoninfo = simplejson.dumps(dict) The output str type 
 Such as: 
info = {'name' : 'jay', 'sex' : 'male', 'age': 22}
jsoninfo = simplejson.dumps(info)
print jsoninfo 
print type(jsoninfo)
     


Related articles: