Files
zaehler/weather3test.py
T
2022-11-04 23:15:29 +01:00

25 lines
688 B
Python

# import the module
import python_weather
import os
def getweather():
# declare the client. format defaults to the metric system (celcius, km/h, etc.)
with python_weather.Client(format=python_weather.METRIC) as client:
# fetch a weather forecast from a city
weather = client.get("Flammersfeld,DE")
# returns the current day's forecast temperature (int)
print("Temp in FFeld: " + weather.current.temperature)
# get the weather forecast for a few days
for forecast in weather.forecasts:
print(forecast)
# hourly forecasts
for hourly in forecast.hourly:
print(f' --> {hourly!r}')
if __name__ == "__main__":
getweather()