2019年3月11日 星期一

用Python把玩方碼QR Code,真的超好玩的

參考資料:Pure python QR Code generator

首先安裝QR Code套件,在cmd命令列上輸入下列命令:
pip install qrcode[pil]


接下來試試直接在命令列上,下達qr命令來生成QR Code。
qr "Nan Kai" > nankai.png


成生的QR Code如下:

試著用程式來撰寫
import qrcode
img = qrcode.make('※就讀南開、成功大門為你開!')
img.save("C:\\Users\\user\\nankai.png")
執行結果:

試著加入容錯率等資料
import qrcode
qr = qrcode.QRCode(
    version=1,
    error_correction=qrcode.constants.ERROR_CORRECT_L,
    box_size=10,
    border=4,
)
qr.add_data('※南開、南開、金石為開!')
qr.make(fit=True)
img = qr.make_image()
img.save("C:\\Users\\user\\nankai.png")
執行結果:


[python] QR code 模組

半色调二维码生成器
raspberry-pi-qr-code-scanner

Playing with Pi, AI and Python

1 則留言: