將圖片檔案轉換為 base64 字串:
將 base64 字串轉換為圖片檔案:
import base64
path = "C:\\Users\\ruyut\\Desktop\\r.png"
with open(path, "rb") as image_file:
encoded_string = base64.b64encode(image_file.read()).decode("utf-8")
print(encoded_string)
將 base64 字串轉換為圖片檔案:
import base64
base64_string = "base64字串"
with open("output.jpg", "wb") as image_file:
image_file.write(base64.b64decode(base64_string))
留言
張貼留言
如果有任何問題、建議、想說的話或文章題目推薦,都歡迎留言或來信: a@ruyut.com