-
Notifications
You must be signed in to change notification settings - Fork 85
Expand file tree
/
Copy pathexample.py
More file actions
43 lines (31 loc) · 1.01 KB
/
example.py
File metadata and controls
43 lines (31 loc) · 1.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# An example of the Python Wrapper for the Forecast.io weather API.
#
# Copyright (c) 2013-2015 Ze'ev Gilovitz <zeev.gil@gmail.com>
#
# Licensed under BSD. All rights reserved.
#
import datetime
import forecastio
def main():
"""
Run load_forecast() with the given lat, lng, and time arguments.
"""
api_key = "YOUR API KEY"
lat = -31.967819
lng = 115.87718
time = datetime.datetime(2015, 2, 27, 6, 0, 0)
forecast = forecastio.load_forecast(api_key, lat, lng, time=time)
print("===========Currently Data=========")
print(forecast.currently())
print("===========Hourly Data=========")
by_hour = forecast.hourly()
print("Hourly Summary: %s" % (by_hour.summary))
for hourly_data_point in by_hour.data:
print(hourly_data_point)
print("===========Daily Data=========")
by_day = forecast.daily()
print("Daily Summary: %s" % (by_day.summary))
for daily_data_point in by_day.data:
print(daily_data_point)
if __name__ == "__main__":
main()