【发布时间】:2020-08-28 17:27:38
【问题描述】:
使用 PyQRCode 我想为下面的图片生成二维码
Zxing解码器在线报道:
Raw text: �R606101.
Raw bytes: 40 98 05 23 63 03 63 13 03 12 e0 ec 11 ec 11 ec
这里是我的 python 脚本
import pyqrcode
import png
from pyqrcode import QRCode
import re
# Raw bytes which represents the QR code
s = "40 98 05 23 63 03 63 13 03 12 e0 ec 11 ec 11 ec"
s = re.sub(r"((?![a-f0-9]).)", "", s)
print(s)
t = bytes.fromhex(s).decode('latin-1')
print(t) # error: it print @˜♣#c♥c‼♥↕àì◄ì◄ì not �R606101.
# Generate QR code
url = pyqrcode.create(t, encoding='latin-1')
# Create and save the png file naming "myqr.png"
url.png('myqr.png', quiet_zone=1, scale = 20)
但上面的代码会产生奇怪的字符和不同的二维码图像
【问题讨论】:
标签: python python-3.x qr-code