July 5, 2024
How To Generate a QR Code Using Python in Only 5 Lines

Programming Script Text Coding Word

A QR code is a square barcode of 2 Dimensions that can be digitally and quickly read by smartphones. They are a convenient way to store all kinds of data in a small space. In this tutorial, you will learn how to generate and read QR codes in Python using qrcode in only 5 lines.

QR code is a square barcode of 2 Dimensions that can be digitally and quickly read by smartphones. They are a convenient way to store all kinds of data in a small space. In this tutorial, you will learn how to generate and read QR codes in Python using qrcode 

How do we use it?

  1. To send Simple texts.
  2. E-mail addresses: Just like texts, you can also send predefined emails.
  3. Phone Numbers: QR codes can also be used to call someone.
  4. Reveal discounts and coupon codes: You can be redirected to the online checkout with the promo code pre-applied if you don’t remember them.
  5. Connect to WiFi without password: You no longer need to share or remember passwords. Scan the QR code and join the WiFi network.
  6. Engage with social media(Like and Follow).
  7. Links to Download apps: You can now scan QR codes to download an app from the App Store.

How to generate it?

Step 1 : Installing Python.

https://www.python.org/downloads/release/python-382/

How To Generate a QR Code Using Python in Only 5 Lines

Step 2 : Test if Python Installed.

How To Generate a QR Code Using Python in Only 5 Lines

Step 3 : Installing Pillow

Pillow is Library that adds support for opening, manipulating, and saving many different image file formats.

pip is an already installed package-management system used to install and manage software packages written in Python.

How To Generate a QR Code Using Python in Only 5 Lines
How To Generate a QR Code Using Python in Only 5 Lines

Step 4 : Installing qrcode Module

How To Generate a QR Code Using Python in Only 5 Lines

Step 5 : Create QrcodeGenerator.py file

import qrcode
# example data
data = "https://hufnews.com"
# output file name
filename = "hufnews.png"
# generate qr code
img = qrcode.make(data)
# save img to a file
img.save(filename)

Step 6 : Generate QR Code image

How To Generate a QR Code Using Python in Only 5 Lines

and here’s the final result

How To Generate a QR Code Using Python in Only 5 Lines

Leave a Reply

Copyright © All rights reserved www.HufNews.com | ChromeNews by AF themes.