23 lines
748 B
Python
23 lines
748 B
Python
|
# -*- coding: utf-8 -*-
|
||
|
from weather import Weather
|
||
|
import datetime
|
||
|
|
||
|
weather = Weather()
|
||
|
loc = weather.lookup_by_location('Poznan')
|
||
|
print('Informacja o aktualnej pogodzie: %s' % loc.condition().text())
|
||
|
|
||
|
def ftoc(f):
|
||
|
return (f-32.0)*5.0/9.0
|
||
|
|
||
|
def date_to_pl_weekday(date_string):
|
||
|
"""
|
||
|
input: string of form '10 Dec 2017'
|
||
|
output: weekday in polish language
|
||
|
"""
|
||
|
idx = datetime.datetime.strptime(date_string, '%d %b %Y').weekday()
|
||
|
return [u'poniedziałek', u'wtorek', u'środa', u'czwartek', u'piątek', u'sobota', u'niedziela'][idx]
|
||
|
|
||
|
min_day = min(loc.forecast(), key = lambda f: f.low())
|
||
|
print(u'Najbliższy najzimniejszy dzień to %s. Będzie %s\u00B0C. ' % (date_to_pl_weekday(min_day.date()), ftoc(int(min_day.low()))))
|
||
|
|