This article is participating in Python Theme Month. See the link for details

Hello everyone, today I found another interesting gadget. I’m an old poet of fun gadgets.

Principle of TWO-DIMENSIONAL code

The principle of two-dimensional code is binary operation. In general, two-dimensional code uses binary 0 and 1 as codes, and at the same time uses several geometric shapes corresponding to binary to represent literal numerical information. Information is recorded using black and white squares that represent squares and can be coded horizontally and vertically.

Know MyQR

MyQR is a third party library in Python dedicated to creating personalized QR codes. The MyQR library needs to be installed before Python can call MyQR.

1, use [Windows] + [R] key to open a dialog box, enter CMD and confirm in the dialog box, you can open the CMD window.

2. Know your Python installation path in a CMD window. Enter pip3 install MyQR and press Enter to download.

Write the code

The main code is as follows:

version, level, qr_name = myqr.run( words="hei girl, i love you", version=1, level='H', picture="1.gif", Colorized = True, contrast = 1.0, brightness = 1.0,Copy the code

Words are the content that is written, which can be a web address. Version is the version level is the control error correction level, the range is L, M, Q, H, ascending from left to right picture is the GIF image to be synthesized

The finished product

Here I use the week star’s confession scene. Of course, you can also replace your own confession picture.

Then the final qr code scan results are like this:

Of course, you can even write a confession in bytes. It’s up to you to do that. The above idea is quite clear. Need to get the full source code, please go to the public number: poetic code. Since come in, original is not easy. Just give me a “like” and leave.