Home >  > GitHub项目探索之一

GitHub项目探索之一

0

1、项目介绍

引用NWS(National Weather Service)的feed,输出天气的Alerts。

2、安装:

pip install -U weatheralerts

Snap18198

3、使用

导入WeatherAlerts类,然后创建WeatherAlerts的实例化对象,实例化时可选参数有:区域代码、州名。

from weatheralerts import WeatherAlerts

# Alerts by a Samecode
nws = WeatherAlerts(samecodes='016027')
for alert in nws.alerts:
    print alert.title

# Alerts for a list of Samecodes
nws = WeatherAlerts(samecodes=['016027','016001','016073','016075'])
for alert in nws.alerts:
    print alert.title

# Alerts for a State
nws = WeatherAlerts(state='ID')
for alert in nws.alerts:
    print "{0}:  {1}".format(alert.areadesc, alert.title)

在Pycharm中的运行结果:
Snap18199

项目地址:https://github.com/zebpalmer/WeatherAlerts

另一个:

https://github.com/astephan83/weather/tree/master/Weather

本文暂无标签

发表评论

*

*