Skip to main content

Create your own QR code using python.

 How to crate your own QR code and embed any link in it !

First of all thanks guys if you are reading this blog, in this blog we will be discussing about how to create our own Quick Response (QR) code and to for this small project we will be using Python Programming language since my blog is all about python 😁. 

Ok so before we dive into this project lets first understand a little about this QR code this thing what is this ? how it become so use full in modern world etc. etc. etc.  


What is QR code ?

A QR code is first invented by an Japanese automotive company named Denso Wave. After since it become so popular. Its because this image or in which it will be generated it can store a huge amount of data only in machine readable form. Its similarity matches to the barcode because both of them have black and white lines randomly in them. Using QR code we can track products, we can make easy payments, also can book our ticket online in one word it's safe to share information using the bar QR code. Generally if you guys don't know how a QR code looks like don't worry, here is how it looks like, and i also embedded my blog link in it so if you will scan (using any scanner) it will automatically open up the blog in your browser. Try it if you want ! and if not don't worry we will discuss it ahead in our blog.


QR code that I generated using python.

So how to use python to generate a QR code !

To do this we will use the QR code library of the Python.

So install it using pip install qrcode.

After installing the library import it "import qrocode". 

so the whole code looks something like this, 

import qrcode

data="https://pythonworkssolution.blogspot.com/2022/09/scrap-pdfs-using-python.htm"

qr_data=qrcode.QRCode(
    version=4,
    error_correction=qrcode.constants.ERROR_CORRECT_L,
    box_size=10,
    border=1
    )

qr_data.add_data(data)
qr_data.make(fit=True)
qr_gen = qr_data.make_image(fill_color="black", back_color="white")
qr_gen.save("blog.png")

So this is the whole code that will generate our QR code, you can make changes to this code as you for that
just play with this code a little. There not much in this code to tell you. As you can see there is a variable
named data. There i have given my blog link, if you want you can give any link there, not only link if you will
your that will be also appear in the browser, for more fun lets say you created an API and deployed it in
any cloud system and you have your website, then you can give that link also here and run the code, see
magic also if you want to make it an API for you we site you can do it using this code, for making API's python
has several frameworks you can use any of them if you want.

Do share this blog with others, it can be helpful for their school or college projects and also kids could get
idea about what QR code is! So this is all in this blog see you guys in my next blog.








Comments

Popular posts from this blog

An Overview on Data Science

So before we get into what is data science let us first understand what is data actually, and how it is important for business, e-Commerce, for security, for identity of someone, even for scientific purpose or research and for even much more. So data is nothing but a piece of information , the information that we are collecting could be anything it can be your date of birth, your body weight, your eyes or hair colour, your meal list, what you are searching in your mobile or computer, the places you visit, so we can say anything around you either connected to you or around you can be data.  But if someone is novice he will ask, how all these things can be data ? Answer is Data is everywhere but what type of data is our need and which type of data is not our need makes the all difference. Lets understand this clearly through an example- Suppose you want to do some shopping on Amazon, and you decided to buy a new mobile phone, you fixed the budget, then features that you want in the t...

All about data analysis and which programming language to choose to perform data analysis?

  What is data analysis ? Data analysis is the process of exploring, cleansing, transforming and modelling data in order to derive useful insight, supporting decision. Tools available for it ! There are two kinds of tools used in order to carry out data analysis: 1) Auto managed closed tools: These are the tools whose source code is not available, that is these are not open source. If you want to use these tools then you have to pay for them. Also, as these tools are not open source, if you want to learn these tools then you have to follow their documentation site. Though some auto managed tools have their free versions available.  Pros & Cons: Closed Source Expensive They are limited  Easy to learn Example: Tableau, Qlik View, Excel (Paid Version), Power BI (Paid Version), Zoho Analytics, SAS 2) Programming Languages: Then there are suitable programming languages which can derive the same result like auto managed closed tools.  Pros & Cons: These are open so...