반응형
Convert Image to Base64 String
import base64
b64_bytes = base64.b64encode(img_file.read())
print(b64_str)
output:
b'f4nhf4ngd4bjfYrjeofidIbhc4XecobdcoffZ4Lfb4XcaoHfc4~~~~~~~~TS11UzyHVEOfUUawUEe2'
The output type is bytes starting with b’.
Or you can say your base64 encoded string is in the pair of single quotation.
In order to remove b’ from the prefix of base64 code in Python,
b64_str = b64_bytes.decode('utf-8')
print(b64_str)
반응형
'연구 관련' 카테고리의 다른 글
ROS1 vs. ROS2 (Short Description) (0) | 2022.03.09 |
---|---|
How to clear the ubuntu terminal (0) | 2021.09.17 |
QGC full window (missing title bar) (0) | 2020.10.17 |
Matlab installation ubuntu (우분투에 매틀랩 설치) (0) | 2020.04.28 |