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,***>`
本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。