Generate two-dimensional code via QRCode
The code for the online tutorials can be used
Simple Rough
Import qrcode img = qrcode.make (' http://lizhiyu.iteye.com/blog/2331662 ') img.save (' test.png ') Add parameter Control Python code import qrcode qr = QRCode. QRCode ( version=1, error_correction=qrcode.constants.error_correct_l, box_size=10, border=4, ) Qr.add_data (' http://lizhiyu.iteye.com/') qr.make (fit=true) img = qr.make_image () img.save (' 123. PNG ')
Parameter meaning:
Version: An integer value of 1~40 that controls the size of the QR code (the minimum value is 1, which is a 12x12 matrix). If you want the program to determine automatically, set the value to None and use the Fit parameter.
Error_correction: Control the error correction function of QR code. The following 4 constants are desirable values.
error_correct_l: About 7% or fewer errors can be corrected.
Error_correct_m (default): Errors of approximately 15% or less can be corrected.
Ror_correct_h: About 30% or fewer errors can be corrected.
Box_size: Controls the number of pixels that each small lattice in the QR code contains.
Border: Control border (the distance between the QR code and the picture boundary) contains the number of squares (the default is 4, which is the minimum value specified by the relevant standard)
1. Classic error, the file name uses the keyword qrcode.py, the modified file name is aaa.py
Attributeerror: ' Module ' object has no attribute ' make '
2. After the correction, the error is as follows, need to install Pilimage package
Traceback (most recent): File "E:\python_test\qrtest\aaa.py", line 3, in <module> img = qrcode.ma Ke (' http://www.xgezhang.com/') File "C:\Python27\lib\site-packages\qrcode\main.py", line one, in make return Qr.make_image () File "C:\Python27\lib\site-packages\qrcode\main.py", line 271, in Make_image from Qrcode.image.pil Import pilimage File "C:\Python27\lib\site-packages\qrcode\image\pil.py", line 8, in <module > Import Image Importerror:no module named image problem 3.pip install pilimage error, due to the use of Windows environment Write tool, directly to piliage official website download exe execution, solve Could not find a version of that satisfies the requirement pilimage (from versions:)
No matching distribution found for Pilimage