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'}