Python USES QRCode module to generate detailed two dimensional code examples

  • 2020-06-03 07:12:35
  • OfStack

Python USES the QRCode module to generate 2d codes

QRCode website

Introduction to the

python-qrcode is a third module for generating 2d code images, which relies on the PIL module and the qrcode library.

Simple usage

import qrcode 
img = qrcode.make('hello, qrcode')'test.png')

Advanced usage

import qrcode 
qr = qrcode.QRCode(   
qr.add_data('hello, qrcode') 
img = qr.make_image()'123.png')

Parameter meaning:

version: Integer values from 1 to 40 that controls the size of the 2-dimensional code (the minimum value is 1, a 12 by 12 matrix). If you want the program to determine automatically, set the value to None and use the fit parameter.

error_correction: Error correction function that controls 2d codes. The following four constants can be taken.
ERROR_CORRECT_L: approximately 7% or less errors can be corrected.
ERROR_CORRECT_M (default) : approximately 15% or less errors can be corrected.
ROR_CORRECT_H: approximately 30% or less errors can be corrected.

box_size: Controls the number of pixels contained in each cell in a 2-dimensional code.

border: The number of cells contained in the control border (the distance between the 2-d code and the image boundary) (the default is 4, which is the minimum specified by the relevant standard)

Thank you for reading, I hope to help you, thank you for your support to this site!

Related articles: