【发布时间】:2021-01-02 18:53:34
【问题描述】:
我有以下 JSON 数据:
{
"status": {
"status_code": 0,
"status_message": "SUCCESS"
},
"device_id": 89911454,
"type": "obs_st",
"source": "cache",
"summary": {
"pressure_trend": "falling",
"strike_count_1h": 0,
"strike_count_3h": 0,
"precip_total_1h": 0.0,
"precip_accum_local_yesterday": 0.0,
"precip_accum_local_yesterday_final": 0.0,
"precip_analysis_type_yesterday": 1,
"feels_like": 33.3,
"heat_index": 33.3,
"wind_chill": 33.3
},
"obs": [
[1600214324, 0, 0, 0, 0, 3, 1012.8, 33.3, 35, 27898, 1.94, 232, 0, 0, 0, 0, 2.56, 1, 0, null, null, 0]
]
}
我只想要“heat_index”的值。在这种情况下,“heat_index”= 33.3。我一直无法弄清楚如何。任何人都可以帮我解决这个问题吗?感谢您提供的任何帮助!
【问题讨论】:
-
myJson['summary']['heat_index']不工作吗? -
感谢您的提示,但每当我这样做时,我都会收到以下错误消息:TypeError: string indices must be integers
-
是的,如果我先这样做,它确实有效:json_data = json.loads(result) 谢谢!