我不熟悉python和json。我有一个下面的json文件,其中需要解析json文件中的“值”
{
"link": [
{
"attributes": [
{
"value": "backup",
"name": "name"
},
{
"value": "",
"name": "description"
}
],
},
{
"attributes": [
{
"value": "com.cap.blueprints",
"name": "name"
},
{
"value": "",
"name": "description"
}
],
}
],
}
我试过下面的代码。但我犯了个错误
with open ("respose_json.txt") as f2:
data=json.load(f2)
for x in data:
print(x['attributes']['value'])
error:
print(x['attributes']['value'])
TypeError: string indices must be integers
link
键李>尝试以下操作:
相关问题 更多 >
编程相关推荐