How to Generate QR Code with Python

In this lesson we want to learn How to Generate QR Code with Python ?


What is QR Code ?

QR code (Quick Response code) is two dimensional barcode that can be scanned using  smartphone camera to quickly access information or website. QR codes are widely used for various purposes, such as storing contact information, URLs, product information and many more. QR codes can store much more information than traditional barcodes and are more good as they can be scanned using a smartphone or QR code reader. QR codes are often used in advertising, marketing, and as a quick and convenient way to access information.



How to Generate QR Code with Python ?

You can generate QR codes with Python using the qrcode library. you can install qrcode library using pip, simply run the following command in your terminal or command prompt:

This will install the latest version of qrcode library and its dependencies. After installation is completed you can start using the library in your Python code by importing it:


This is basic example:

This code creates QR code that encodes the URL and saves it in to a file named qrcode.png. you can customize QR code by adjusting the parameters of QRCodeobject, such as the version (size), error_correction level, box_size and border. make_image function allows you to set the fill color and background color of the QR code.



Learn More on Python


Leave a Comment