Python uses the QRCode module to generate a QR code instance.
Python uses the QRCode module to generate a QR code
QRCode Official Website
Https://pypi.python.org/pypi/qrcode/5.1
Introduction
Python-qrcode is a third-party module used to generate QR code images. It depends on the PIL module and qrcode library.
Simple usage
import qrcode img = qrcode.make('hello, qrcode')img.save('test.png')
Advanced usage
import qrcode qr = qrcode.QRCode( version=1, error_correction=qrcode.constants.ERROR_CORRECT_L, box_size=10, border=4, ) qr.add_data('hello, qrcode') qr.make(fit=True) img = qr.make_image()img.save('123.png')
Parameter description:
Version: The value ranges from 1 ~ The integer of 40, which controls the size of the QR code (the minimum value is 1, which is a 12 × 12 matrix ). If you want the program to determine automatically, set the value to None and use the fit parameter.
Error_correction: controls the error correction function of the QR code. You can set the following four constants.
ERROR_CORRECT_L: errors of about 7% or fewer can be corrected.
ERROR_CORRECT_M (default): errors of about 15% or fewer can be corrected.
ROR_CORRECT_H: errors of about 30% or fewer can be corrected.
Box_size: controls the number of workers contained in each small grid in the QR code.
Border: number of cells contained in the control border (the distance between the QR code and the Image Boundary) (default value: 4, which is the minimum value specified by relevant standards)
Thank you for reading this article. I hope it will help you. Thank you for your support for this site!