File: current_weather.py

package info (click to toggle)
python-datapoint 0.13.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 584 kB
  • sloc: python: 3,062; makefile: 18
file content (18 lines) | stat: -rw-r--r-- 572 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#!/usr/bin/env python
"""
This is a simple example which will print out the current weather and
temperature for our location.
"""

import datapoint

# Create datapoint connection
manager = datapoint.Manager(api_key="aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee")

# Get a forecast for the nearest location
forecast = manager.get_forecast(51.500728, -0.124626, "hourly")

# Get the current timestep using now() and print out some info
now = forecast.now()
print(now["significantWeatherCode"])
print(f"{now['screenTemperature']['value']} {now['screenTemperature']['unit_symbol']}")