Hey Guys, welcome to Proto Coders Point , in this Python Tutorial we will implement qr code generator using pyqrcode library.
What is pyqrcode library/module?
The pyqrcode library is a qr code generator, By using this module we can easily develop QR code with pure python.
This Library can be used for building or creating QR codes, Then you can save the QR coder with is generated as SVG,PNG and plain text.
Let’s begin implementation of the library
Step 1 : Create New Python project or open existing project
Off-Course you need to create a new Python Project to work on this QR code generator tutorial
File > New Project
Step 2 : Create a new Python file to handle QR code generator
You need to create a new python file where you can write python code
Right click on Project > New > Python File
i have created a new python file with name as ” QRCodeGenerator”
Step 3 : Add pyqrcode library in your python project
How to install the pyqrcode module ?
File > Setting > Project Interpretor > Click on ” + ” > Search for “pyqrcode” then select the package and then click on install package button.
Step 4 : open the python file “QRCodeGenerator”
# Import QRCode from pyqrcode import pyqrcode from pyqrcode import QRCode # String which represent the QR code result s = "www.protocoderspoint.com" # Generate QR code url = pyqrcode.create(s) # Create and save the png file naming "myqr.png" url.svg("myqr.svg", scale=8)
As you have added or installed the pyqrcode module in your project now you can just import the pyqrcode library and use them in your code.
we have initialized a string “s” that holds a website address.
then pyqrcode.create(s) : Here are we passing the string that holds url of website to create a QR Code in PYTHON
and then this url variable is passed to create a new Image of that QR Code with is been generated.
Now just Run the project and you will see a QR Code as below image
you can just scan the QR Code and check the result will open the browser with protocoderspoint.com