We can create QR code for any url link using Python. QR creation using python code is very easy to execute and user friendly to edit. Python code is given below for ready use.
Solution: How to generate QR Code using python for a URL.
Pre-Requisite:
1. System should have Python 3.x.x version
2. Environment variable should set
Optional:
Jupyter Notebook is not mandatory but can help in debugging and showing results on same page
Note: This code is specific for the qr code generation of URL links we generally use in user manuals, devices and documents.
Code Section: (SVG Format)
import pyqrcod from pyqrcode import QRCode # Taking a website for example (You can change as per your need) se = "www.se.com/" # Create QR code link = pyqrcode.create(se) # Save qr code in svg file format naming "sepic.svg" link.svg("sepic.svg", scale = 8)e
Results:
Image file “sepic.svg” generated at base location.
import pyqrcode import png from pyqrcode import QRCode # Change your content here se = "www.se.com/" # Create QR code link = pyqrcode.create(se) # Create and save in png file naming "sepic.png" link.png('sepic.png', scale = 6)Code for QR Code
Results:
Image file “sepic.png” generated at base location.
Open image and check with google lens
Note: If you are able to understand above code, you can leave this article here but if you want to learn about the reason of written lines, you can find it below.
Library Explanations:
import pyqrcodeLibrary Import
import png
from pyqrcode import QRCode
- pyqrcode module is used here for QR code creation. Encoding methods for qr code generation in the library “pyqrcode” are as per required standard.
- png library is used for saving created images in PNG format.
# Change your content here
Next Line
se = “www.se.com/”
URL link assigned in se variable.
# Create QR codeNext Line
link = pyqrcode.create(se)
QR code created using pyqrcode.create() and assigned in variable “link”.
# Create and save in png file naming "sepic.png"Last Line
link.png('sepic.png', scale = 6)
Value assigned in variable “link” further saved with “link.png(‘sepic.png, scale = 6)”
If you have any queries regarding this article or if I have missed something on this topic, please feel free to add in the comment down below for the audience. See you guys in another article.
You can visit our home page for more python codes here.
Stay Connected Stay Safe. Thank you
0 Comments