metalexs
@metalexs

Как можно задублировать bot.send_message?

Как можно разбить отправку при считывании строк из файла, что бы не плодить bot.send_message?
В file_p список вида ['https://site.ru', 'https://site.ru', 'https://site.ru', 'https://site.ru']
file = open("text.txt", "r" )
            file_r = file.read()
            file_p = re.findall("'(.+?)'", file_r)

            bot.send_message(message.chat.id, str(file_p[0]), reply_markup=markup)
            bot.send_message(message.chat.id, str(file_p[1]), reply_markup=markup)
            bot.send_message(message.chat.id, str(file_p[2]), reply_markup=markup)
            bot.send_message(message.chat.id, str(file_p[3]), reply_markup=markup)
            bot.send_message(message.chat.id, str(file_p[4]), reply_markup=markup)
      
и т.д
  • Вопрос задан
  • 91 просмотр
Решения вопроса 1
Dr_Elvis
@Dr_Elvis Куратор тега Python
В гугле забанен
Как то так
file = open("text.txt", "r" )
    file_r = file.read()
    file_p = re.findall("'(.+?)'", file_r)

    for x in file_p:
        bot.send_message(message.chat.id, str(x), reply_markup=markup)
Ответ написан
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы