请问,在python 中如何将一个string 转成 list[dicts] ?
我有个string,内容如下:
str_content = '''
[
{
"Id": "Failure",
"Description": null,
"Event": [],
"RowId": 1
},
{
"Id": "Virtual",
"Description": null,
"Event": [],
"RowId": 2
},
{
"Id": "Cleaning",
"Description": null,
"Event": [],
"RowId": 3
}
]
'''
怎么可以把 str_content 转成list[dicts]
就是变成一个list,list 里面是字典格式?
回答
expected_result_converted = json.loads(expected_result) # return a list[dicts]
THE END
二维码