如果是IBM Weather Company Data预测,哪个键给出了预测的白天和夜晚部分的最高和最低温度?我目前正在使用:
nightHigh = result.forecasts [0] .night.hi;
nightLow = result.forecasts [0] .night.wc;
以下是从API调用中收到的JSON。
{
"metadata": {
"language": "en-US",
"transaction_id": "1500467819366:918701294",
"version": "1",
"latitude": 36.11,
"longitude": -115.17,
"units": "e",
"expire_time_gmt": 1500469259,
"status_code": 200
},
"forecasts": [
{
"class": "fod_long_range_daily",
"expire_time_gmt": 1500469259,
"fcst_valid": 1500472800,
"fcst_valid_local": "2017-07-19T07:00:00-0700",
"num": 1,
"max_temp": 98,
"min_temp": 81,
"torcon": null,
"stormcon": null,
"blurb": null,
"blurb_author": null,
"lunar_phase_day": 25,
"dow": "Wednesday",
"lunar_phase": "Waning Crescent",
"lunar_phase_code": "WNC",
"sunrise": "2017-07-19T05:38:06-0700",
"sunset": "2017-07-19T19:55:22-0700",
"moonrise": "2017-07-19T02:05:45-0700",
"moonset": "2017-07-19T16:14:29-0700",
"qualifier_code": null,
"qualifier": null,
"narrative": "More clouds than sun. Highs in the upper 90s and lows in the low 80s.",
"qpf": 0,
"snow_qpf": 0,
"snow_range": "",
"snow_phrase": "",
"snow_code": "",
"night": {
"fcst_valid": 1500516000,
"fcst_valid_local": "2017-07-19T19:00:00-0700",
"day_ind": "N",
"thunder_enum": 0,
"daypart_name": "Tonight",
"long_daypart_name": "Wednesday night",
"alt_daypart_name": "Tonight",
"thunder_enum_phrase": "No thunder",
"num": 2,
"temp": 81,
"hi": 95,
"wc": 82,
"pop": 0,
"icon_extd": 2900,
"icon_code": 29,
"wxman": "wx1600",
"phrase_12char": "P Cloudy",
"phrase_22char": "Partly Cloudy",
"phrase_32char": "Partly Cloudy",
"subphrase_pt1": "Partly",
"subphrase_pt2": "Cloudy",
"subphrase_pt3": "",
"precip_type": "rain",
"rh": 44,
"wspd": 9,
"wdir": 135,
"wdir_cardinal": "SE",
"clds": 61,
"pop_phrase": "",
"temp_phrase": "Low 81F.",
"accumulation_phrase": "",
"wind_phrase": "Winds SE at 5 to 10 mph.",
"shortcast": "Partly cloudy",
"narrative": "Partly cloudy skies. Low 81F. Winds SE at 5 to 10 mph.",
"qpf": 0,
"snow_qpf": 0,
"snow_range": "",
"snow_phrase": "",
"snow_code": "",
"vocal_key": "D2:DA02:X3000300021:S300021:TL81:W06R02",
"qualifier_code": null,
"qualifier": null,
"uv_index_raw": 0,
"uv_index": 0,
"uv_warning": 0,
"uv_desc": "Low",
"golf_index": null,
"golf_category": ""
},
"day": {
"fcst_valid": 1500472800,
"fcst_valid_local": "2017-07-19T07:00:00-0700",
"day_ind": "D",
"thunder_enum": 0,
"daypart_name": "Today",
"long_daypart_name": "Wednesday",
"alt_daypart_name": "Today",
"thunder_enum_phrase": "No thunder",
"num": 1,
"temp": 98,
"hi": 99,
"wc": 90,
"pop": 10,
"icon_extd": 2800,
"icon_code": 28,
"wxman": "wx1230",
"phrase_12char": "M Cloudy",
"phrase_22char": "Mostly Cloudy",
"phrase_32char": "Mostly Cloudy",
"subphrase_pt1": "Mostly",
"subphrase_pt2": "Cloudy",
"subphrase_pt3": "",
"precip_type": "rain",
"rh": 36,
"wspd": 11,
"wdir": 137,
"wdir_cardinal": "SE",
"clds": 75,
"pop_phrase": "",
"temp_phrase": "High 98F.",
"accumulation_phrase": "",
"wind_phrase": "Winds SE at 10 to 15 mph.",
"shortcast": "More clouds than sun",
"narrative": "Mostly cloudy. High 98F. Winds SE at 10 to 15 mph.",
"qpf": 0,
"snow_qpf": 0,
"snow_range": "",
"snow_phrase": "",
"snow_code": "",
"vocal_key": "D1:DA01:X2600280011:S280013:TH98:W06R03",
"qualifier_code": null,
"qualifier": null,
"uv_index_raw": 8.22,
"uv_index": 8,
"uv_warning": 0,
"uv_desc": "Very High",
"golf_index": 7,
"golf_category": "Good"
}
}
],
"address": "Las Vegas",
"temperatureUnits": "fahrenheit",
"phrase": "You don't need umbrella. Today's rain fall probability is 10% in Las Vegas."
}
答案 0 :(得分:0)
wc
是风寒的指标,而不是最低温度。
您最接近的是result.forecasts[:].max_temp
和result.forecasts[:].min_temp
,这是全天最高和最低温度的关键。
您似乎正在使用'日内预测' API。如果您选择'每小时预测' API,您将收到每小时温度数据,这样您就可以分析白天和夜晚的最小/最大值