In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-10 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article introduces you how to use Python to make dynamic QR code, the content is very detailed, interested friends can refer to, hope to be helpful to you.
How to realize the production of dynamic QR code with one line of code?
It is easy to use and can be installed directly through pip.
Pip3 install myqr
After the installation is complete, you can generate the QR code you want. Yes! It's that simple.
Ordinary QR code
Just execute the following code directly
# myqr QR Code content > myqr http://weixin.qq.com/r/khy5oY7EN9NIrcrC90mA
The corresponding QR code image is generated in the current directory, and the default name is qrcode.png.
If you need to modify the name or path of the generated QR code, you can do so with the following command:
-n: the name of the custom QR code
-d: customize the path of the QR code
For example: generate a Python3X.jpg QR code picture, the path is in the root directory of the E disk
Myqr http://weixin.qq.com/r/khy5oY7EN9NIrcrC90mA-n Python3X.jpg-d E:\
For a QR code, you can customize its size and fault tolerance and correction capabilities.
-v: defines the size of the QR code, which ranges from 1 to 40. The default size depends on what you enter.
-l: define the error correction rate of the QR code, that is, the occluded part of the QR code is still identified, and there are four levels, namely L (7%), M (15%), Q (25%) and H (30%). The default is the highest level of H.
Such as generating a QR code with a size of 10 and an error correction rate of M
Myqr http://weixin.qq.com/r/khy5oY7EN9NIrcrC90mA-v 10-l M
Generate art QR code
Sometimes, in order to attract people's attention, the effect of ordinary QR codes will be inadequate. So it can be in the form of an art QR code, and the way to generate it is very simple.
For example, I found a picture of Peggy Pig on the Internet.
If you want Piggy Page to combine with our QR code, you can do it with the-p command, and the way is very simple, still one line of code.
Myqr http://weixin.qq.com/r/khy5oY7EN9NIrcrC90mA-p peiqi.jpg
But, the result doesn't seem to be what we want. It turned out to be black and white.
At this point, you need to use another command-c, for the coloring of the image.
Myqr http://weixin.qq.com/r/khy5oY7EN9NIrcrC90mA-p peiqi.jpg-c
After the implementation, did you find that the effect was much better?
If you need to change the contrast of the picture, or the brightness. This can be done in two ways
-con: modifies the contrast of the image. The default is 1.0.
-bri: modify the brightness of the image. The default value is also 1.0.
Generate a dynamic QR code.
Dynamic QR code
Art QR code although much better, but still can not achieve our purpose of installing X, so, you can have a dynamic QR code.
The way is the same as the above art QR code, the only difference is that the picture must be gif. The default is also black and white, so you need to add-c
The code is as follows:
Myqr http://weixin.qq.com/r/khy5oY7EN9NIrcrC90mA-p pig.gif-n Python3X.gif-c
Effect picture:
EXE file
If you don't have a Python3 environment on your computer at this time, or you don't want to install qrcode. An exe program is also provided here. This program is packaged by PyInstaller. In the process of testing, it is found that the speed of generating QR code is sometimes fast and sometimes slow. The specific reason is unknown.
Use method, is not very complex, just need to create an exe file in the sibling directory, create an info.txt file, enter the corresponding parameters, if you need to generate art QR code, you also need to add the picture or gif file you used in the same directory.
The info.txt is as follows:
# QR code content words= http://weixin.qq.com/r/khy5oY7EN9NIrcrC90mA# size v1 picture (gif) path p=pig.gif# output the name of the QR code n=Python3X.gif# color C
It should be noted that the comments in the above content are only for the purpose of explaining that the annotated Chinese characters need to be deleted in the process of use, otherwise an error will be compiled.
After the configuration is completed, execute myqr.exe to generate the QR code you need in the current directory. If it cannot be generated normally, please execute the exe file in cmd.
What is not clear, welcome to leave a message!
On how to use Python to make dynamic QR code to share here, I hope the above content can be of some help to you, can learn more knowledge. If you think the article is good, you can share it for more people to see.
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.