Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/python-3.x/16.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 3.x 我可以把savfig发送到python电报机器人吗_Python 3.x_Matplotlib_Telegram_Telegram Bot_Python Telegram Bot - Fatal编程技术网

Python 3.x 我可以把savfig发送到python电报机器人吗

Python 3.x 我可以把savfig发送到python电报机器人吗,python-3.x,matplotlib,telegram,telegram-bot,python-telegram-bot,Python 3.x,Matplotlib,Telegram,Telegram Bot,Python Telegram Bot,我尝试添加bot.sendPhoto(chat\u id=chat\u id,photo=''),在这里我有savfig,需要将图像发送到我的电报bot import telebot from flask import Flask, request token = '9542...................ke8nT10' URL = 'http://re......here.com/' bot = telebot.TeleBot(token, threaded=False) bot

我尝试添加bot.sendPhoto(chat\u id=chat\u id,photo=''),在这里我有savfig,需要将图像发送到我的电报bot

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 in code:函数发送到我的电报机器人。发送照片(聊天id,photo=open('plot\u name.png','rb'))

您尝试过先下载照片吗?例如,在urllib的帮助下,然后通过sendPhoto发送(chat_id=chat_id,photo=open('file.png','rb')?在Pythonywhrre服务器中有代码,我如何在那里下载
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)