File tree Expand file tree Collapse file tree 1 file changed +33
-0
lines changed Expand file tree Collapse file tree 1 file changed +33
-0
lines changed Original file line number Diff line number Diff line change 1+ from pyowm import OWM
2+ from pyowm .utils import config
3+ from pyowm .utils import timestamps
4+
5+ # ---------- FREE API KEY ---------------------
6+
7+ owm = OWM ('your-API-key' ) # You MUST provide a valid API key
8+
9+ # Search for current weather in London (Great Britain)
10+ mgr = owm .weather_manager ()
11+ observation = mgr .weather_at_place ('London,GB' )
12+ w = observation .weather
13+ print (w ) # <Weather - reference time=2013-12-18 09:20, status=Clouds>
14+
15+ # Weather details
16+ w .wind () # {'speed': 4.6, 'deg': 330}
17+ w .humidity () # 87
18+ w .temperature ('celsius' ) # {'temp_max': 10.5, 'temp': 9.7, 'temp_min': 9.0}
19+
20+ # Search current weather observations in the surroundings of
21+ # lat=22.57W, lon=43.12S (Rio de Janeiro, BR)
22+ observation_list = mgr .weather_around_coords (- 22.57 , - 43.12 )
23+
24+
25+ # ---------- PAID API KEY ---------------------
26+
27+ config_dict = config .get_default_config_for_subscription_type ('professional' )
28+ owm = OWM ('your-paid-api-key' , config_dict )
29+
30+ # Will it be clear tomorrow at this time in Milan (Italy) ?
31+ mgr = owm .weather_manager ()
32+ forecast = mgr .daily_forecast ("Milan,IT" )
33+ forecast .will_be_clear_at (timestamps .tomorrow ()) # The sun always shines on Italy, right? ;)
You can’t perform that action at this time.
0 commit comments