[英]trying to get a bot to send a photo using pytelegrambotapi but i keep getting the filenotfounderror
so i'm just trying to make a telegram bot for my friends birthday that's coming up soon and i am a super beginner at python and coding, know my basics here and there so please be nice.所以我只是想为即将到来的朋友生日制作一个电报机器人,我是 python 和编码的超级初学者,在这里和那里了解我的基础知识,所以请善待。 i'm using pytelegrambotapi and replit to code my bot, basically, i want the bot to send some images after a command has been triggered right.
我正在使用 pytelegrambotapi 和 repli 对我的机器人进行编码,基本上,我希望机器人在正确触发命令后发送一些图像。 and i'm seriously copying the code for the image path correctly but somehow this error keeps popping up.
我正在认真地正确复制图像路径的代码,但不知何故,这个错误不断弹出。 help!
帮助!
photo1 = open(r"C:\Users\User\Desktop\bday\IMG_2201.PNG", 'rb')
@bot.message_handler(commands=['photo'])
def msg4(message):
bot.send_photo(message.chat.id, photo1)
my code on replit and the error我的 repli 代码和错误
what i think im supposed to code for my bot to send an image我认为我应该为我的机器人编写代码以发送图像
There's the problem with your path python support //
您的路径存在问题 python 支持
//
Change you path to this
C://Users//User//Desktop//bday//IMG_2201.PNG
将路径更改为此
C://Users//User//Desktop//bday//IMG_2201.PNG
if you give the correct path then this code will work for you
如果您提供正确的路径,那么此代码将为您工作
photo1 = open("C://Users//User//Desktop//bday//IMG_2201.PNG", 'rb')
@bot.message_handler(commands=['photo'])
def msg4(message):
bot.send_photo(message.chat.id, photo1)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.