1 后端python生成base64
import os import base64 with open('../static/img/user-icon.jpg','rb') as f: data=f.read() encodesstr=base64.b64encode(data) # 转换 print(str(encodesstr,'utf-8')) # 必须指定编码
2 前端进行渲染
`<img src="data:image/png;base64,***>`
1 后端python生成base64
import os import base64 with open('../static/img/user-icon.jpg','rb') as f: data=f.read() encodesstr=base64.b64encode(data) # 转换 print(str(encodesstr,'utf-8')) # 必须指定编码
2 前端进行渲染
`<img src="data:image/png;base64,***>`