我有一个表示为
的字符串'[{"Name": "Joe","LastName":"Doe","Classes:"[CS3302,CS3306,CS4469]"},{"Name": "Mathew","LastName":"Lee","Classes:"[CS3312,CS3301,CS4161]"}]'
如何将其转换为词典列表并从中读取数据?
答案 0 :(得分:0)
您可以使用json.loads()
import json
str = '[{"Name": "Joe","LastName":"Doe","Classes":"[CS3302,CS3306,CS4469]"},{"Name": "Mathew","LastName":"Lee","Classes":"[CS3312,CS3301,CS4161]"}]'
output = json.loads(str)
请注意,“班级”键后缺少引号