import pyowm
city = input("Какой город вас интересует?: ")
owm = pyowm.OWM('a99967bc9ee70d5b4bd387902982f400', language = "RU")
observation = owm.weather_at_place(city)
w = observation.get_weather()
temperature = w.get_temperature('celsius')['temp']
print("В городе " + city + " сейчас температура: " + str(temperature) + " по Цельсию.")
print('Погода в указаном городе: ' + w.get_detailed_status())
import pyowm
from pyowm.commons.enums import SubscriptionTypeEnum
from pyowm.utils.measurables import kelvin_to_celsius
city = 'Krasnodar'
config = {
'subscription_type': SubscriptionTypeEnum.FREE,
'language': 'ru',
'connection': {
'use_ssl': True,
'verify_ssl_certs': True,
'use_proxy': False,
'timeout_secs': 5
},
'proxies': {
'http': 'http://user:pass@host:port',
'https': 'socks5://user:pass@host:port'
}
}
owm = pyowm.OWM('a99967bc9ee70d5b4bd387902982f400', config=config)
mgr = owm.weather_manager()
observation = mgr.weather_at_place(city)
w = observation.weather
print("В городе " + city + " сейчас температура: " + str(kelvin_to_celsius(w.temp['temp'])) + " по Цельсию.")
print('Погода в указаном городе: ' + observation.location.name)
class OWM:
"""
Entry point class providing ad-hoc API clients for each OWM web API.
:param api_key: the OWM API key
:type api_key: str
:param config: the configuration dictionary (if not provided, a default one will be used)
:type config: dict
"""
def __init__(self, api_key, config=None):
assert api_key is not None, 'API Key must be set'
self.api_key = api_key
if config is None:
self.config = cfg.get_default_config()
else:
assert isinstance(config, dict)
self.config = config
owm = pyowm.OWM('a99967bc9ee70d5b4bd387902982f400', {'language': 'ru'})