Answer the question
In order to leave comments, you need to log in
Error in code, what am I doing wrong?
When I try to run it, I get an error:
File "telegram.py", line 30
expect:
^
SyntaxError: invalid syntax
Here is the code itself:
from pyowm import OWM
import time
from pyowm.utils.config import get_default_config
config_dict = get_default_config()
config_dict['language'] = 'ru'
import telebot
owm = OWM('api')
bot = telebot.TeleBot("token")
@bot.message_handler(func=lambda m: True)
def send_echo(message):
try:
mgr = owm.weather_manager()
observation = mgr.weather_at_place( message.text )
w = observation.weather
temp = w.temperature('celsius')["temp"]
owm.weather_at_place(place)
answer = "В городе " + message.text + " сейчас " + w.detailed_status + "\n"
answer += "Температура сейчас в районе " + str(temp) + "\n\n"
if temp < 0:
answer += "Сейчас ппц как холодно, одевайся как капуста."
elif temp < 20:
answer += "Сейчас прекрасная погодка, одевай что хочешь"
else:
answer += "Сейчас ппц как жарко, можешь идти в майке и шортах."
bot.send_message(message.chat.id, answer)
expect:
bot.send_message(message.chat.id, 'Ошибка! Город не найден!')
bot.polling( none_stop = True )
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question