python取数组最后一个元素_Python Json。只获取json数组中的最后一个元素
我剛開始嘗試python,現在我有點左右為難。在
我試圖從一個json文檔打印,而我只得到數組中的最后一個元素。在[{
"FullMeasure": "1/2 cup",
"FullWeight": "",
"IngredientGridHeaders": null,
"IngredientID": 1142,
"IngredientName": "frozen corn",
"IngredientStep": 10,
"LanguageId": 0,
"PostPreparation": ", thawed, drained",
"PrePreparation": "",
"QuantityNum": 0,
"QuantityText": "1/2",
"QuantityUnit": "cup",
"RecipeIngredientID": 6291555,
"TrialMeasure": "",
"TrialWeight": ""
},
{
"FullMeasure": "1/4 cup",
"FullWeight": "",
"IngredientGridHeaders": null,
"IngredientID": 1523,
"IngredientName": "red pepper",
"IngredientStep": 20,
"LanguageId": 0,
"PostPreparation": "s",
"PrePreparation": "chopped",
"QuantityNum": 0,
"QuantityText": "1/4",
"QuantityUnit": "cup",
"RecipeIngredientID": 6291554,
"TrialMeasure": "",
"TrialWeight": ""
},
{
"FullMeasure": "2 Tbsp.",
"FullWeight": "",
"IngredientGridHeaders": null,
"IngredientID": 20197,
"IngredientName": "chopped green chiles",
"IngredientStep": 30,
"LanguageId": 0,
"PostPreparation": ", drained",
"PrePreparation": "canned ",
"QuantityNum": 2,
"QuantityText": "2",
"QuantityUnit": "Tbsp.",
"RecipeIngredientID": 6291552,
"TrialMeasure": "",
"TrialWeight": ""
},
{
"FullMeasure": "",
"FullWeight": "",
"IngredientGridHeaders": null,
"IngredientID": 19682,
"IngredientName": "KRAFT DELI DELUXE Process American Cheese Slice",
"IngredientStep": 80,
"LanguageId": 0,
"PostPreparation": "s",
"PrePreparation": "",
"QuantityNum": 4,
"QuantityText": "4",
"QuantityUnit": "",
"RecipeIngredientID": 6291558,
"TrialMeasure": "",
"TrialWeight": ""
}
]
我想得到所有的ingredientID,所以我寫了一段代碼來獲取ingredientID
^{pr2}$
當我返回值時,我得到{
"Ingreient ID": 19682
}
我試圖得到每種元素的成分ID,但我似乎搞不清楚。如有任何建議,我們將不勝感激。謝謝你
總結
以上是生活随笔為你收集整理的python取数组最后一个元素_Python Json。只获取json数组中的最后一个元素的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: python无效的类字符串_Python
- 下一篇: 对于频繁的写数据处理方式