1、项目介绍
引用NWS(National Weather Service)的feed,输出天气的Alerts。
2、安装:
1 |
pip install -U weatheralerts |

3、使用
导入WeatherAlerts类,然后创建WeatherAlerts的实例化对象,实例化时可选参数有:区域代码、州名。
1 |
from weatheralerts import WeatherAlerts |
4 |
nws = WeatherAlerts(samecodes= '016027' ) |
5 |
for alert in nws.alerts: |
8 |
# Alerts for a list of Samecodes |
9 |
nws = WeatherAlerts(samecodes=[ '016027' , '016001' , '016073' , '016075' ]) |
10 |
for alert in nws.alerts: |
14 |
nws = WeatherAlerts(state= 'ID' ) |
15 |
for alert in nws.alerts: |
16 |
print "{0}: {1}" .format(alert.areadesc, alert.title) |
在Pycharm中的运行结果:

转载请注明:XAMPP中文组官网 » GitHub项目探索之一