Homework1 = open('Homework.txt','r')
Homework = Homework1.read()
Homework1.close()
Homework = (Homework1)
with open('Homework.txt', 'r', encoding='utf-8') as f:
homework = f.read()
# ....
@bot.message_handler(commands=['Homework', 'homework'])
def send_homework(message):
if not homework:
bot.send_message(message.chat.id, 'У меня пока нет домашнего задания')
else:
bot.send_message(message.chat.id, homework)