This repository has been archived on 2026-08-27. You can view files and clone it. You cannot open issues or pull requests or push a commit.
2022-02-03 20:02:38 +08:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
|
# -- coding:utf-8 --
|
|
|
|
|
# @Author: markushammered@gmail.com
|
|
|
|
|
# @Development Tool: PyCharm
|
|
|
|
|
# @Create Time: 2022/2/3
|
|
|
|
|
# @File Name: base2img.py
|
|
|
|
|
|
|
|
|
|
import base64
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def convert() -> None:
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
:return:
|
|
|
|
|
"""
|
|
|
|
|
# image转base64
|
2022-02-06 13:02:11 +08:00
|
|
|
with open(f'../../static/example.png', 'rb') as f:
|
|
|
|
|
base64_data = base64.b64encode(f.read())
|
|
|
|
|
base64_code = 'data:image/jpeg;base64,' + base64_data.decode('utf-8')
|
|
|
|
|
print(base64_code)
|
2022-02-03 20:02:38 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
convert()
|