How to generate QR Code using Python

Search for a command to run...

hi nice and appreciate your information. https://www.mygroundbiz.online/
The series content will mostly cover Technical Python tutorials and my recent learnings and experience in Python.
When you create a python program and you want to share it with the world and you want them to run your script without having to install python. You can do this by converting the .py file to .exe file. In this article, I will show you how you can do i...
All you need to know about Hacktoberfest 2021

Hello reader! Well, Hacktoberfest is something, you are gonna hear a lot about in the coming month. You can refer to my YouTube video Tutorial to see a working tutorial for better understanding and a step-by-step guide of the same. https://www.yo...

Hello reader! In this Blog post, I will share some useful code snippets and functions in Python. Give it a read. Let's get started! 1. Memory The method getsizeof can be used to retrieve the size of any object. Here's an example of the same. import...

Hello reader! Whenever a client sends a request to the server, the response always contains a status code. You might not see it always but it's returned at every client-server interaction. Well, even if you are not a programmer, you would still know...

Hello reader! Microsoft subsidiary GitHub launched Copilot to power pair programming with AI. In this blog post, I will share all you need to know about it. You can refer to my YouTube video Tutorial to see a working tutorial for better understandin...

You all must have heard about or seen a lot of QR codes, I was thinking to create one for my blogging website and I decided to do the same with python. How cool right?
Do you wish to know how to create one? Here's how you can do it!
You can also refer to the YouTube Tutorial video of the same.
Repository for Ultimate Resource in python. Drop a star if you find it useful! Got anything to add? Open a PR on the same!
1. Basic knowledge about Python
2. Basic knowledge about QR Code
3. pyqrcode module
Let's understand the basics!
QR is short for Quick Response. A QR code is a type of matrix barcode first designed in 1994 for the automotive industry in Japan. A barcode is a machine-readable optical label that contains information about the item to which it is attached.
While QR Codes and Barcodes are similar in practice, QR Codes contain more information because they have the ability to hold information both horizontally and vertically.
Barcodes only use horizontal information.
A Static QR Code contains information that is fixed and uneditable once the Code has been generated.
Usecases:
Dynamic QR Codes allow you to update, edit and modify the type of the QR Code however many times you need i.e. the content is editable.
Usecases:
Now that you have a basic understanding of what a QR code is, let's create one!
You can find all the code at my GitHub Repository.

Open your terminal and run the following command.
pip install pyqrcode
pip install pypng
Pyqrcode module is used to create QR Codes. It is designed to be as simple and as possible. It does this by using sane defaults and autodetection to make creating a QR Code very simple.
Once Installed now we can import it inside our python script. So first create a new python file.
Import the pyqrcode package inside the python script using the following command.
import pyqrcode
Next, we need some text that we want to convert as our QR Code. Since I am creating the QR Code for my blogging website, I will ayushirawat.com as data here. Let's store inside a variable.
data = 'ayushirawat.com'
Now that we have the data with us, we can move forward and make use of the package we just imported. Let's create an object, I am naming it as img.
img = pyqrcode.create(data)
We will use the create method (as it results in a cleaner looking code) on data.
Now let's store it in .png format with proper scaling.
img.png('blogwebsite.png', scale= 10)
That's it, simple isn't it? Let's see our result!

This is the QR Code of my Blog Website. Scan and check it out!
I hope this helped in understanding how to create to your own QR Code with python. You can find all the Code at my GitHub Repository.
You can connect with me on Twitter.
You should definitely check out my other Blogs:
Resource:
See you in my next article, Take care!