使用
BytesIO及以后
depre()
工作实例
from flask import Flask#from flask import render_templateimport matplotlib.pyplot as pltimport ioimport base64app = Flask(__name__)@app.route('/plot')def build_plot(): img = io.BytesIO() y = [1,2,3,4,5] x = [0,2,1,3,4] plt.plot(x,y) plt.savefig(img, format='png') img.seek(0) plot_url = base64.b64enpre(img.getvalue()).depre() return '<img >'.format(plot_url)if __name__ == '__main__': app.debug = True app.run()


