Answer the question
In order to leave comments, you need to log in
What to do with "connection" error?
import telebot
import pyowm
owm = pyowm.OWM("ключ", {'language': 'ru'})
bot = telebot.TeleBot("ключ")
@bot.message_handler(content_types=['text'])
def repeat_all_messages(message):
pogoda = owm.weather_manager()
observation = pogoda.weather_at_place(message.text)
w = observation.get_weather()
temp = w.get_temperature('celsius')["temp"]
answer = ("В городе " + message.text + "сейчас " + w.get_detailed_status() + ", температура " + str(temp) + " градусов")
bot.send_message(message.chat.id, answer)
bot.polling(none_stop=True)<code lang="python">
</code>
Answer the question
In order to leave comments, you need to log in
Because to select a language, you can’t just pass a single language value, you need a complete dictionary of settings (in which we are already changing the language).
from pyowm.utils.config import get_default_config
# создаем словарь настроек по умолчанию и в нем уже меняем язык
config_dict = get_default_config()
config_dict['language'] = 'ru'
owm = pyowm.OWM("ключ", config_dict)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question