【发布时间】:2017-07-19 08:04:41
【问题描述】:
我是 python 新手,遇到了问题。我想使用以下代码发送一些带有电报机器人的照片。例如,我想发送 5 张具有不同 URL 的图像,我用不同的 URL 在下面写了 5 次代码。我的问题是当其中一个 URL 错误或不响应我的代码时例如,如果第一个 URL 有问题,其他 4 个 sendPhoto 没有运行,我希望我的代码继续并发送其他 4 个图像。任何人有任何解决方案吗?
def start(bot, update):
bot.sendPhoto(chat_id='chat_id', photo='URL1',caption="caption")
bot.sendPhoto(chat_id='chat_id', photo='URL2',caption="caption")
bot.sendPhoto(chat_id='chat_id', photo='URL3',caption="caption")
bot.sendPhoto(chat_id='chat_id', photo='URL4',caption="caption")
bot.sendPhoto(chat_id='chat_id', photo='URL5',caption="caption")
【问题讨论】:
-
提供更多代码。你试过捕捉错误吗?
-
是的,我使用 try: 除了每个 bot.sendPhoto 但我又遇到了同样的问题
标签: python telegram telegram-bot python-telegram-bot