Make your own dynamic QR code with two lines of code

Insert picture description here
Insert picture description here
Insert picture description here
The pictures and code in this article are from the well-known blogger "Little Gray Ape" , please support the original author if you like it, thank you!

To generate a QR code in Python, you need to call the MYQR third-party library. This library can be said to be tailor-made for QR codes. Calling the run function of this module can directly generate the desired QR code.

To generate a normal QR code, you only need to pass the link to generate the QR code to the words parameter in the run. For example, we want to generate the QR code on the main interface of the 360 ​​browser: the URL is: "https://hao. 360.com/", the code and renderings are as follows:

from MyQR import myqr
myqr.run(words='https://hao.360.com/'

Insert picture description here
When generating an artistic QR code with pictures, we need to add the picture parameter to the original program to indicate the background image of the QR code we want to set. Use the colorized=True parameter to set the background of the picture to color. If not set, The default generated picture is a black and white background. Effect picture with artistic photos:

from MyQR import myqr
myqr.run(words='https://hao.360.com/',
         picture='Sources/mtsc_body15.png',
         save_name='qr1.png',
         colorized=True)

Insert picture description here
In fact, the dynamic QR code is similar to the artistic QR code with pictures. We only need to change the background image to GIF, and change the format of the generated QR code image to GIF. Take the beautiful GIF picture of Yui Aragaki as an example:

from MyQR import myqr
myqr.run(words='https://hao.360.com/',
         picture='Sources/gakki.gif',
         save_name='qr4.png',
         colorized=True)

Insert picture description here

In addition to the parameters mentioned above, there are many parameters that can be used when generating a QR code inside the run function. Here, Big Bad Wolf shares with you the common parameters in the run function:

Insert picture description here
Insert picture description here
  This article is an excerpt. Students who like python can pay attention to the original author "Grey Little Ape" . I borrowed flowers to present the Buddha and it is not worth mentioning. By the way, the front-end learning will be more fun, if you have a certain understanding or do not understand the front-end , Please check my top article, I can make progress with you, that is my greatest expectation.

Original link

Guess you like

Origin blog.csdn.net/weixin_45820444/article/details/108743855