Python and QR Code
Hello friends, welcome to our site. Today we are going to learn a simple and small thing (or technology) QRCode generation in python. QRCode is todays trending technology used to transfer data with just one image. You can use QRCode for payment like paytm, phonepay etc payment gateways.In modern life school or colleges are also using qr code attendance system.
or you can share your wifi password by simply converting password into one qrcode and pasting it onto any wall of your office where any one can scan it and get connected. There are various uses of QRCode. We are not going to discuss them all. Our today’s goal is to learn how to create qrcode or how to generate qrcode into python and convert any string into qrcode image. So let’s start with qrcode generation . To do today’s task we need library to be installed into python. so open your terminal and execute the following command into terminal.
pip3 install qrcode
Here we need qrcode library to create and convert any text into qrcode. So get install this library. After successful installation open python3 shell by executing python3 command into command prompt and start writing code as given below
import qrcode img = qrcode.make('www.solutionstouch.com') print(type(img)) #(output)<class 'qrcode.image.pil.PilImage'> print(img.size) #(output)(330, 330) img.save('website.png')
As here you can see we have passed www.solutionstouch..com as sample text to generate a simple qrcode and saved it as website.png you can choose whatever name you want to give to your image and you can choose any text you want to convert into qrcode.
After the img.save(‘website.png’) command, the qrcode will be generated at the desired directory (or here in the current working directory). Now you can you this qrcode anywhere you want to use.
For Now we will stop here. In next blog we will move forward to learn how to decode the qrcode using python. Till then try this with your own. If any error persist feel free to comment below. We will solve problem regarding this code asap.