Vahid
4 supporters
Python QRCode generator in three lines o ...

Python QRCode generator in three lines of code!

Mar 01, 2022

In this tutorial we are making a QRCode generator using the qrcode library in Python.

I will use the QR Code generator in python by installing qrcode and pillow. Another option is to :

pip install qrcode[pil]

The following three lines of code are used to make a simple QRCode:

import qrcode
img = qrcode.make("Some information here")
img.save("some_file.png")
#The following is for more options
# Link for website
link = "https://www.youtube.com/c/Pythonology"
#Creating an instance of qrcode
qr = qrcode.QRCode(
        version=1,
        box_size=10,
        border=5)
#Adding the data to the qr code
qr.add_data(link)
#Adjusting the size
qr.make(fit=True)
#Customizing the color of the squares and background and then saving it
img = qr.make_image(fill='black', back_color='white')
img.save('qrcode001.png')

Here is the video tutorial:

Enjoy this post?

Buy Vahid a coffee

More from Vahid