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:
pip install qrcode
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:
# create QR code
qr = qrcode.QRCode(
# add data to be encoded in QR code
data = "https://www.google.com"
# generate image from QR code
img = qr.make_image(fill_color="black", back_color="white")
# save image to file
This code creates QR code that encodes the URL https://www.example.com 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
- Python Best Libraries for Web Development
- How to Make an Instagram Bot
- How to send Message to Instagram with Python
- Build Python REST API with FastAPI
- Python Best Frameworks for Web Development
- Why to Use Python for Web Development
- How to Install TKinter in Windows and Linux