代码:figfile=BytesIO
plt.savefig(figfile)
figfile.seek(0)
figdata_png = base64.b64encode(figfile.getvalue()) # 将图片转为base64
figdata_str = str(figdata_png, "utf-8") # 提取base64的字符串
html = ''.format(figdata_str)
filename='png.html'
with open(filename,'w') as f:
f.write(html)
发生异常: TypeError
descriptor 'write' for '_io.BytesIO' objects doesn't apply to a 'bytes' object
File "E:\wzb\wzb\mat.py", line 38, in
plt.savefig(figfile)