导入
当前天气状况
学习如何获取当前天气状况数据。
| 参数 | 类型 | 分类 | 说明 |
|---|---|---|---|
| API_KEY | string | 必需 | 这是我们的API密钥。这是一个查询参数。 |
| locationKey | integer | 必需 | 这是位置的唯一标识符。仅在特定位置端点中作为路径参数使用。 |
| group | integer | 必需 | 这是城市数量。允许的值为50、100和150。仅在热门城市端点中作为路径参数使用。 |
| language | string | 可选 | 返回结果所使用的语言。默认值为“en-us”。这是一个查询参数。 |
| details | boolean | 可选 | 设置为“True”以在响应中包含完整详情,否则设置为“False”。默认值为“False”。仅在特定位置端点中作为查询参数使用。 |
1locationKey = 351409 2group = 50 3 4url1Day = 'http://dataservice.accuweather.com/currentconditions/v1/' \ 5 + str(locationKey) + '?apikey={{API_KEY}}' 6 7url5Day = 'http://dataservice.accuweather.com/currentconditions/v1/topcities/' \ 8 + str(group) + '?apikey={{API_KEY}}' 9 10res1Day = requests.get(url1Day) 11res5Day = requests.get(url5Day) 12 13printResponse(res1Day) 14printResponse(res5Day)
| 参数 | 类型 | 说明 |
|---|---|---|
| HasPrecipitation | boolean | 表示是否有降水。 |
| IsDayTime | boolean | 表示当前是否为白天。 |
| Temperature | object | 温度信息,单位为华氏度。 |
| RealFeelTemperature | object | “体感温度”,单位为华氏度。 |
| Wind | object | 包含风速和风向信息。 |
| RelativeHumidity | integer | 湿度数值。 |
| UVIndex | integer | 紫外线辐射强度指数。该值可能为NULL。 |
| Visibility | object | 可见度相关信息。 |
| Link | string | AccuWeather网站上详细天气预报的链接。 |
| MobileLink | string | AccuWeather移动网站上详细天气预报的链接。 |
| 参数 | 类型 | 说明 |
|---|---|---|
| Key | string | 城市的唯一位置标识符。 |
| LocalizedName | string | 以请求语言显示的位置名称,默认语言为“en-us”。 |
| Country | object | 包含城市所属国家的信息,包括国家代码、本地化名称和英文名称。 |
| Timezone | object | 包含城市所在时区的信息。 |
| Geoposition | object | 包含城市地理坐标信息。 |
| IsDayTime | boolean | 表示当前是否为白天。 |
| Temperature | object | 提供华氏度和摄氏度两种单位的温度数据。 |
| HasPrecipitation | boolean | 表示是否有降水。 |
| Link | string | AccuWeather网站上详细天气预报的链接。 |
| MobileLink | string | AccuWeather移动网站上详细天气预报的链接。 |