<Using Python to customize the generation of simple QR codes>——"Python Project Combat"

Table of contents

1. Question guidance

2. Implementation steps

(1) Find and install the third-party library qrcode

(2) Write code and embed built-in information

(3) Use the scanning tool to read the information

Postscript: ●Due to the limited level of the author, the article inevitably contains some errors. Readers are welcome to correct me. There are many slang words in this article. I sincerely hope for your advice!

                                                                           ——By Author: Xinxiao·Old Knowing


My CSDN blog address link:

 

1. Question guidance

The application of QR codes brings great convenience to people's lives. However, how is the QR code generated?

A QR code essentially uses a black and white dot matrix to represent a character string, and transmits the information in the form of an image through some conversion rules. However, the QR code in life is more of a URL (web address). After scanning the code, it will automatically jump to the corresponding address, thus opening a web page. So how do we use Python to custom generate a simple QR code?

2. Implementation steps

(1) Find and install the third-party library qrcode

Here we need to use Python's third-party library. First, log in to the pypi official website to find the qrcode documentation library.

Official website link: PyPI · The Python Package Index

 

 

 

Note: Here is the installation on the command line!

 Tips for successful installation:

(2) Write code and embed built-in information

import qrcode

img = qrcode.make('Hello,World!')  #这里添加需要添加的URL或文本等
img.save('qrcode.png')

(3) Use the scanning tool to read the information

Use WeChat, Baidu and other apps to scan the code to read: Use WeChat or other tools to scan the code to see the content of the QR code.

 

 

 illustrate:

The use of Python here is just to customize the generation of simple QR codes, and generate more rich QR codes (for example: dynamic QR codes, colored QR codes, etc. If you are interested, you can refer to the online tutorial for learning).

Postscript:
●Due to the limited level of the author, there are inevitable errors in the article. Readers are welcome to correct the article, and the article is full of slang, and I sincerely hope to give advice!

                                                                           ——By Author: Xinxiao·Old Knowing

Guess you like

Origin blog.csdn.net/m0_57859086/article/details/128808768