Today, we are going to use Python to make a cool QR code, which can be moved
Stop talking nonsense, let's start making it~
Article Directory
-
- Install MyQR
- CMD generates image QR code
- Use Python to generate (look at friends who failed to generate)
- Make an animated QR code & black and white QR code
- Actual combat: Make your own QQ/WeChat QR code
- If you have any questions, please discuss in the comment section
- Hope this article can be of some help to you
- END
Install MyQR
1. Clickwin+rTo enter the running page:
2. Entercmd, Clickdetermine:
3. Open the page and enter 'pip install myqr -i https://pypi.tuna.tsinghua.edu.cn/simple'You can download myqr at high speed
To achieve permanent high-speed download, please see: How to achieve high-speed download with python pip
CMD generates image QR code
First of all, we have to prepare a picture. Here I took a picture of SpongeBob Squarepants and placed it on the desktop:
imy.jpg
Then:
1. Open cmd according to the above method
2. Enter the following code in cmd:
myqr -c -v20 -p 你的图片名(必须在桌面上) 链接
Such as myqr -c -v20 -p imy.jpg https://blog.csdn.net/CSDN_C2
3. View the generated QR code:
Isn’t it cool?
Use Python to generate (look at friends who failed to generate)
Let us first look at the parameter table:
In fact, it is very simple, two lines of code:
from MyQR import myqr
myqr.run(words=链接,version=20,level='H',picture=图片路径,colorized=True,save_dir=图片所在位置)
python 注:路径中的’\‘要写成'\\';picture=图片路径中的’图片路径‘要加图片本身,如'C:\\Users\\Administrator\\Desktop\\imy.jpg',save_dir=图片所在位置中的'图片所在位置'不要加图片本身,如'C:\\Users\\Administrator\\Desktop\\'
such as:
from MyQR import myqr
myqr.run(words='https://blog.csdn.net/CSDN_C2',version=20,level='H',picture='C:\\Users\\Administrator\\Desktop\\imy.jpg',colorized=True,save_dir='C:\\Users\\Administrator\\Desktop\\')
Check out the results!
Make an animated QR code & black and white QR code
1. Make a two-dimensional code for moving pictures
Here, I prepared a moving picture, which has been placed on the desktop:
Then, we only need to change the file path. After you press Enter, you can start a black game, because a GIF consists of hundreds or thousands of GIFs, and the resolution is about n times that of a jpg picture (in fact, it is not so exaggerated, generally GIF emoticons For dozens of frames)
Huhu, after waiting for more than ten minutes, I finally completed the 13.63MB picture (because I couldn't upload it, I could only cut it down). It looks like this:
2. Make a black and white QR code,
just change the colorized parameter to False
from MyQR import myqr
myqr.run(words=链接,version=20,level='H',picture=图片路径,colorized=是否为彩色,save_dir=图片所在位置)
We use imy.jpg again as an example.
Results:
Actual combat: Make your own QQ/WeChat QR code
Some friends may ask: Why did I make my own QQ/WeChat QR code, even though it was written according to the above, it still cannot be scanned? You may only use QQ\WeChat ID to replace the link, and the phone will be confused: what does the number here mean? Is it a phone number? A QQ number? A game number? So he would never understand his meaning. So we should convert it into a link, and you will get to that interface after scanning.
1. Save our QQ/WeChat plus friends QR code, payment code and other QR codes to the computer
2. Then we have to enter https://cli.im/deqr/ in the browser
3. After entering, drag the QR code up
4. Get the decoding
5. Enter the command:
Note:
1. If there is an & in the decoding link, enter quotation marks to wrap the & in the cmd.
2. If it cannot be scanned, please zoom out the lens
. 3. Do not have any obstructions on the QR code, otherwise it will not be scanned come out