top of page
Writer's pictureAusaf Abbas

Python QR Code Generator

Updated: Jul 11, 2020

Before starting the project we need to install some necessary modules: pyqrcode and pypng.

Open your cmd and type these commands separately.

  1. pip install pyqrcode

  2. pip install pypng

Now lets create a variable named with text. Then assign it the text we need to encrypt.

text='I Love Knowcubs'

Create a variable named with qrcode and create qrcode by calling 'create' method of pyqrcode module.

qrcode=pyqrcode.create(text)

Now let’s make it in a png file.

qrcode.png(‘qrcode.png’,scale=15)

Here we take variable qrcode and convert it into png file, pass the name of the file as a string and give a value for the scale.

Let’s open QR Code we have two ways to open it:

1. With the help of OS module

Os.system(‘qrcode.png’)

2. Go to the folder where the program is and open .png file form there.


Complete Code

Code for generating QR code in Python


Generated QR Code













74 views0 comments

Recent Posts

See All

댓글


bottom of page