P
P
Python Newbie2021-08-25 20:12:39
Python
Python Newbie, 2021-08-25 20:12:39

How to change language to pyowm in 2021?

There is a code:

from pyowm import OWM
from pyowm.utils import config
from pyowm.utils import timestamps

owm = OWM('d4bfb9a2a08c4fd186672544bb41491c')

mgr = owm.weather_manager()


city = input("Введите город: ")

observation = mgr.weather_at_place(city)
w = observation.weather
temperatur = w.temperature('celsius')
temperatur = temperatur['temp']
status = w.detailed_status
print(status)
print(temperatur)


How to draw a conclusion in Russian in 2021?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey Karbivnichy, 2021-08-25
@Levman5

How to change language to pyowm in 2021?
Just like 50 years ago - that is, with the help of documentation.
So you can get a list of supported languages:
from pyowm.owm import OWM
owm = OWM('d4bfb9a2a08c4fd186672544bb41491c')
languages = owm.supported_languages
print(languages)
>>>['af', 'al', 'ar', 'az', 'bg', 'ca', 'cz', 'da', 'de', 'el', 'en', 'es', 'eu', 'fa', 'fi', 'fr', 'gl', 'he', 'hi', 'hr', 'hu', 'id', 'it', 'ja', 'kr', 'la', 'lt', 'mk', 'nl', 'no', 'pl', 'pt', 'pt_br', 'ro', 'ru', 'se', 'sk', 'sl', 'sp', 'sr', 'sv', 'th', 'tr', 'ua', 'uk', 'vi', 'zh_cn', 'zh_tw', 'zu']

So you can get the current configuration:
from pyowm.owm import OWM
owm = OWM('d4bfb9a2a08c4fd186672544bb41491c')
config_dict = owm.configuration
print(config_dict)
>>>{'subscription_type': <pyowm.commons.databoxes.SubscriptionType - name=free subdomain=api paid=False>, 'language': 'en', 'connection': {'use_ssl': True, 'verify_ssl_certs': True, 'use_proxy': False, 'timeout_secs': 5}, 'proxies': {'http': 'http://user:[email protected]:port', 'https': 'socks5://user:[email protected]:port'}}

Well, you can change the language like this:
from pyowm.owm import OWM
from pyowm.utils.config import get_default_config
config_dict = get_default_config()
config_dict['language'] = 'ru'
owm = OWM('d4bfb9a2a08c4fd186672544bb41491c', config_dict)

PyOWM code recipes

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question