Generate QR Code In Python
1 min read
QR code (Quick Response code) is a two-dimensional barcode or matrix barcode. It was initially intended for the automotive industry but became popular outside the automotive industry due to its fast readability and higher storage capacity than standard UPC barcodes. QR code often used to contain data for a locator, identified, or tracker that points to a website or application. And lately, it is has been used extensively as a part of the payment process.
In this article, I will show you the simplest way to generate QR code using Python.
First off, you need to have the
qrcode package installed in your environment.
$ pip install qrcode
Generate QR code
Now that you have installed the package, you can start generating QR code.
import qrcode # Set our data. data = "Hello, QR world." # Generate the QR code # qr = qrcode.QRCode() # Add data to our QR code qr.add_data(data) # Generate the QR code image qr_img = qr.make_image()
You can view the result by invoking the
And you can save the result to a file by invoking the