Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
1 Trả lời
5698 Lượt xem

Hello,

How to store QR code in Base64 to PNG image file using Python3?

I need to print QR code on the form and have Base64 string of the QR code.

Thanks in advance!


Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

Hi

Try to add this method to your function

import io, base64
from PIL import Image

# Assuming base64_str is the value of the byte, the value not convert to bytes you can use base64.decodebytes(data)

img = Image.open(io.BytesIO(base64_str)
img.save(
'my-image.jpeg')

Hope it helps

Ảnh đại diện
Huỷ bỏ