我有一個(gè)愚蠢的問題。所以基本上,有JSON文件的分配,例如,我需要找到只包含我現(xiàn)在需要的信息的JSON文件,并打印包含我需要的信息的文件名?
這里有一個(gè)例子:我有一個(gè)文件所在的目錄,這是JSON文件包含的信息
{
"version": "1.0.4",
"room": {
"index": 2,
"label": "Bedroom",
"score": 0.999368429,
"threshold": 0.6,
"raw": {
"Balcony": {
"index": 0,
"score": 0.000324130058
},
"Bathroom": {
"index": 1,
"score": 8.77380371e-05
},
"Bedroom": {
"index": 2,
"score": 0.999368429
},
"Dining Room": {
"index": 3,
"score": 0.000696450472
},
"Garage": {
"index": 4,
"score": 0.000141739845
},
"Hallway": {
"index": 5,
"score": 3.37660313e-05
},
"Kitchen": {
"index": 6,
"score": 4.11570072e-05
},
"Laundry Room": {
"index": 7,
"score": 9.4473362e-06
}
,...
}
}
}
現(xiàn)在我需要找到所有包含"label": "Bedroom"
的JSON文件并打印這些文件名。這是給我的。我在學(xué)習(xí)。提前謝謝。
您可以循環(huán)查看當(dāng)前目錄中的文件,并檢查其中是否包含所需的信息。