forked from tdwojak/Python2017
21 lines
752 B
Python
21 lines
752 B
Python
|
#pip install --user weather-api
|
||
|
from datetime import datetime
|
||
|
from weather import Weather
|
||
|
weather=Weather()
|
||
|
city="Poznan"
|
||
|
weather_city=weather.lookup_by_location(city)
|
||
|
print("Aktualna pogoda in "+city+" :", weather_city.condition().text())
|
||
|
|
||
|
def ftoC(t):
|
||
|
return round(5/9 * (t-32),3)
|
||
|
|
||
|
daymap={0:"Poniedziałek",1:"Wtorek",2:"Środa",3:"Czwartek",4:"Piątek",5:"Sobota",6:"Niedziela"}
|
||
|
tmin=[]
|
||
|
dates=[]
|
||
|
for item in weather_city.forecast():
|
||
|
dates.append(item.date())
|
||
|
tmin.append(ftoC(int(item.low())))
|
||
|
|
||
|
|
||
|
print("Minimana temperatura w dniach "+dates[0]+" - " + dates[-1]+ " to " + str(min(tmin)) +"C przewidywana na dzień "+ dates[tmin.index(min(tmin))] + " ("+daymap[datetime.strptime(dates[tmin.index(min(tmin))],'%d %b %Y').weekday()]+").")
|