Introduction
Based on Wikipedia:
QR code is a type of matrix barcode invented in 1994. A barcode is a machine-readable optical label that can contain information about the item to which it is attached. A QR Code often contain data for a locator, identifier, or tracker that points to a website or application.
Python Libraries
In order to produce the popular image of the QR code you need the following libraries in Python:
1. PyQRCode (when installing via pip) or QRCode (when installing via conda)
2. pypng (when installing via pip)
import pyqrcode as qr (import qrcode as qr)
import pypng
QR Code -Text
Why always QR Codes has to be links? Text can also do the work if we would like.
For example:
With qrcode library
text_qr = qr.make(‘Thanks for reading me!’)
text_qr.save(‘filename.png’)
With pyqrcode library
text_qr = qr.create(‘Thanks for reading me!’)
text_qr.png(‘filename.png’, scale = 2)
where scale defines the size of the exported png file.
QR Code — Link
text_qr = qr.make(‘https://www.google.com’)
text_qr.save(‘filename.png’)
Conclusion
Once again, Python surprises us with the several capabilities that it offers. So, next time you want to produce some QR Codes, Python will do the work for you easily and fast!