一个最小的预报,我的客户。

requests-forecast的Python项目详细描述


Build StatusCoverage StatusRequirements StatusLatest Package VersionDownload Status

有关完整的文档和api选项,请参见:https://developer.forecast.io/docs/v2

要求

  • Python2.5+
  • 请求1.2.0+

安装

要安装请求预测,只需:

$ pip install requests-forecast

快速启动

创建客户机

>>> from requests_forecast import Forecast
>>> forecast = Forecast(apikey='FORECAST_API_KEY', latitude=38.9717, longitude=-95.235)

获取当前条件

>>> current = forecast.get_currently()
>>> print current['temperature']
58.9

获取分钟条件

>>> current = forecast.get_minutely()
>>> current['summary']
u'Mostly cloudy for the hour.'
>>> current['data'][0].keys()
[u'precipIntensity', u'time']

获取小时条件

>>> current = forecast.get_hourly()
>>> current['temperature']
59.52


>>> forecast.get_hourly()['summary']
Mostly cloudy until tomorrow afternoon.

>>> forecast.get_hourly()['data'][0]['temperature']
>>> 59.52

获得日常条件

>>> forecast.get_daily()['summary']
u'Mixed precipitation off-and-on throughout the week; temperatures peaking at 70\xb0 on Sunday.'
>>> forecast.get_daily()['data'][0]['temperatureMax']
63.85
>>> forecast.get_daily()['data'][0]['temperatureMin']
35.05

获取警报

>>> forecast.alerts()
{
  "expires": 1366898400,
  "uri": "http://alerts.weather.gov/cap/wwacapget.php?x=KS124EFAC89CD0.FreezeWarning.124EFAD6F320KS.TOPNPWTOP.8ab7d76a4db42b9136a1a6849a631097",
  "title": "Freeze Warning for Douglas, KS"
}

示例用法

from datetime import datetime
from requests_forecast import Forecast

forecast = Forecast(apikey='YOUR-API-KEY')
data = forecast.get(latitude=38.9717, longitude=-95.235)

>>> forecast.get_currently()['temperature']
58.9

data = forecast.get(latitude=38.9717, longitude=-95.235,
    time=datetime(year=2013, month=12, day=29))

>>> forecast.get_currently()['temperature']
58.9

>>> forecast.get_currently()['temperature']
36.75

许可证

新BSD

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java在Android中维护应用程序状态   javajavacc:如何指定在特定上下文中需要哪些令牌?   java为什么改型会在重新加载数据时设置以前的响应?   java如何将键转换为字符串,反之亦然   java JDOM解析器插入#固定手动属性   java按元素对XML数据排序?   java Android中有哪些哈希算法?   java为什么使用可选返回类型进行单元测试失败?   Gson和argonauts使用Gson将javascript数组转换为json字符串并转换为javapojo时遇到的问题。试图让我的结构正确   java中的空格   java SQLite高分,草率IndexOutofBounds Android   使用Spring OAUTH2的java Make客户端   netbeans如何在java中创建一个JPopupMenu,其中包含一个要复制文本的项