当先锋百科网

首页 1 2 3 4 5 6 7

python里面字符串转换为字典?

如果字符串能够修改为下面这种,就可以直接json处理:

import json

s = '''{"id1": 1, "name1": "张三", "description1": "mmmmmm", "id2": 2, "name2": "李四", "description2": "NNNNNNN", "id3": 3, "name3": "王五", "description3": "TTTTT"}'''

print json.loads(s,encoding='UTF-8')