python-3.x - 我可以将 savfig 发送到 python 电报机器人吗
问题描述
我尝试添加 bot.sendPhoto(chat_id=chat_id, photo=' http://s33.postimg.org/plci93h4v/image.png '),我有 savfig 并且需要将图像发送到我的电报机器人
import telebot
from flask import Flask, request
token = '9542...................ke8nT10'
URL = 'http://re......here.com/'
bot = telebot.TeleBot(token, threaded=False)
bot.remove_webhook()
bot.set_webhook(url=URL)
app = Flask(__name__)
@app.route('/', methods=['POST'])
def webhook():
update = telebot.types.Update.de_json(request.stream.read().decode('utf-8'))
bot.process_new_updates([update])
return 'ok',200
def code:
plt.savefig('plot_name.png', dpi = 300)
@bot.message_handler(commands=['start']) # welcome message handler
def start(message):
bot.sendPhoto(chat_id=chat_id)
我正在尝试将 savfig 以代码:功能发送到我的电报机器人
解决方案
bot.send_photo(chat_id, photo=open('plot_name.png', 'rb'))
推荐阅读
- php - 如何解决方法不允许必须是以下之一:PUT IN php
- css - 将图标添加到 CSS 边框的末尾
- machine-learning - 训练模型后的最佳权重是多少?最低损失?验证损失?
- javascript - 地图如何使用js处理(字符串,数组列表)?
- matlab - MATLAB 2014b getframe 导致 UI 为“空白”
- python-3.x - IndexError: List Index out of range Keras Tokenizer
- java - Java 对象列表按未排序的特定对象排序
- javascript - 如何使用 php 在不损失质量的情况下增加图像大小
- pdf - 使用 imagemagick 将 pdf 转换为图像并且缺少字体时指定默认替换字体
- excel - 如何根据另一组单元格中的文本更改一个单元格的文本颜色