Python | Generate QR Code using pyqrcode module
Let’s see how to generate QR code in Python using pyqrcode module.
pyqrcode module is a QR code generator. The module automates most of the building process for creating QR codes. This module attempts to follow the QR code standard as closely as possible. The terminology and the encodings used in pyqrcode come directly from the standard.
Installation
$ pip install pyqrcode
pyqrcode.create(content, error='H', version=None, mode=None, encoding=None) : When creating a QR code only the content to be encoded is required, all the other properties of the code will be guessed based on the contents given. This function will return a QRCode object.
One can specify all the properties of required QR code through the optional parameters of the pyqrcode.create() function. Below are some properties:
error: This parameter sets the error correction level of the code.
version: This parameter specifies the size and data capacity of the code.
mode: This parameter sets how the contents will be encoded.
Below is the code:
# Import QRCode from pyqrcode import pyqrcode from pyqrcode import QRCode # String which represent the QR code s = "www.geeksforgeeks.org" # Generate QR code url = pyqrcode.create(s) # Create and save the png file naming "myqr.png" url.svg("myqr.svg", scale = 8) |
Output:


Recommended Posts:
- Secrets | Python module to Generate secure random numbers
- How to generate byte code file in python ?
- pwd module in Python
- grp module in Python
- struct module in Python
- Pygorithm module in Python
- Python | Calendar Module
- OS Path module in Python
- Pathlib module in Python
- Pylatex module in python
- OS Module in Python with Examples
- C Extension Module using Python
- C API from Extension Module in Python | Set 1
- Python Urllib Module
- C API from Extension Module in Python | Set 2
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.



