Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to generate super-NICE QR code with Python

2025-03-29 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/02 Report--

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!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report