Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

How to generate super-NICE QR code with Python

Shulou Source: shulou.com Published: 2022-06-02 02:45:30 09月30日 Update

How to use Python to generate super-NICE QR code, I believe that many inexperienced people do not know what to do, so this paper summarizes the causes of the problem and solutions, through this article I hope you can solve this problem.

1 give a few examples first

This is a QR code plus a static picture.

The QR code can also be made dynamic by adding a gif:

2 how to realize

First of all, this is a project based on github: https://github.com/sylnsfar/qrcode

Configuration: using a window system, as well as a PyCharm compiler. Other configurations can be checked in the project github address.

The first step

Download this project first.

Step two

Then unzip it, and you will have these files:

Step three

Then set the qrcode-master file as the source file, and many people will not import the .py file in pycharm because it is not set up!

The fourth step

Then create your own .py script file:

From MyQR import myqr

Import os

Picture_name = 'map'

Version, level, qr_name = myqr.run (

'https://mp.weixin.qq.com/mp/profile_ext?action=home&__biz=MzI4NzE4NTM3OQ==&scene=124#wechat_redirect',

Version=5

Level='L'

Picture=picture_name+'.gif'

Colorized=True

Contrast=1.0

Brightness=1.0

Save_name='output_'+picture_name+'.gif'

Save_dir=os.getcwd ()

)

[the focus of this article is to explain these parameters]

The first parameter of myqr.run () is the URL, which can be any URL or url. Here is the url of the official Wechat account (by the way); version can range from 1 to 40, indicating the size of the QR code; level is the level of error correction, which can be'L','M','Q 'and' hinge, rising from left to right; picture is the path of the picture or gif; colorized is whether the QR code is generated in color. Contrast adjusts the contrast of the image. 1. 0 represents the original image, and a smaller value indicates lower contrast, and vice versa. The default is 1.0. Brightness is used to adjust the brightness of the picture, and the rest uses and values are the same as contrast; save_name is the name that generates the QR code; save_dir is the path to generate the QR code.

After reading the above, have you mastered how to use Python to generate super-NICE QR codes? If you want to learn more skills or want to know more about it, you are welcome to follow the industry information channel, thank you for reading!

Tags: 2D QR code that is generation picture file project content parameter contrast method more URL path problem adjustment configuration original same helpless Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Tech Info Shulou Information NVidia vpn Huawei