python 字典格式的字符串转为字典

python 字典格式的字符串转为字典

例如:

param_dir = '{ "name": "zsh", "age": 18}'

要求:把上述的数据转化为

param_dir = { "name": "zsh", "age": 18} 

使用json模块

import json


param_dir= '{"name" : "zsh", "age": 18}'
user_dict = json.loads(param_dir)
# user_dict = {u'gender': u'male', u'age': 28, u'name': u'john'}

  

 
posted @ 2021-04-30 17:41  zhuang6  阅读(717)  评论(0编辑  收藏  举报