Python uses the QRCode module to generate a QR code instance.

Source: Internet
Author: User

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!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.