发送照片没有压缩,Telegrambot文件
如何将照片发送到不压缩的情况下作为文件。当我使用当前方法实现它时,文件将作为文档发送而无需扩展。
bot = TeleBot("API")
@bot.message_handler(content_types=['text'])
def send(message):
with open("5.jpg", "rb") as file:
f = file.read()
bot.send_document(message.chat.id, document=f)
bot.polling(True)
How do I send a photo to chat without compression, as a file. When I implement it with the current method, the file is sent as a document without an extension.
bot = TeleBot("API")
@bot.message_handler(content_types=['text'])
def send(message):
with open("5.jpg", "rb") as file:
f = file.read()
bot.send_document(message.chat.id, document=f)
bot.polling(True)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
当您
与
document = f
结合使用时,Telegram将接收文件的内容。要使用原始FILENAMEM发送文件,请从File 从
open()
:When you do
Combined with
document=f
, Telegram will receive the content of the file.To send the file with the original filenamem, pass the
file
variable fromopen()
: