Dynamic QR code
Function commonly used parameter table
Today I want to share with you a Python Two lines of code to show the operation of small projects , Generate your own beautiful QR code , Including ordinary QR code 、 Art QR code and dynamic QR code with pictures . Let's start with the last wave of renderings :
Ordinary QR code
Art QR code with pictures
Dynamic QR code
Okay , The next step is to see how to use two lines of code to generate your own QR code .
stay Python To generate a two-dimensional code, you need to call MYQR Third party Library , This library can be said to be specially tailored for two-dimensional code , Call the run Function can directly generate the desired two-dimensional code ,
.
Ordinary QR code
========================================================================
To generate a normal QR code, you only need to run Middle feeding words The QR code to be generated can be passed in , For example, we will 360 The browser's main interface generates a QR code : The website is :“https://hao.360.com/”.
Run the following code :
from MyQR import myqr
myqr.run(words='https://hao.360.com/')
Be accomplished , At this time, we can find the generated in the default folder of the program .png Format of the QR code .
.
Art QR code with pictures
============================================================================
When generating art QR code with pictures , We need to add... To the original program picture Parameters , The background image of the QR code we want to set , Use colorized=True Parameter setting picture background color , If you don't set , The default image is black and white background .
We can also use save_name Parameter name the QR code .
It is worth noting that : To avoid image format errors , The format of the named QR code needs to be the same as that of the background image .
For example, we use pictures “mtsc_body15.png” Generate a QR code for the background . The generated QR code is named “qr1.png”
The code is as follows :
from MyQR import myqr
myqr.run(words='https://hao.360.com/',
picture='Sources/mtsc_body15.png',
save_name='qr1.png',
colorized=True)
The effect of the generated QR code is as follows :
.
Hand drawn as shown in the figure below kafka Knowledge outline flow chart (xmind The file can't be uploaded , Export picture presentation ), But you can provide source files to every friend who loves learning , For a link : Free download here
xmind The file can't be uploaded , Export picture presentation ), But you can provide source files to every friend who loves learning , For a link : Free download here
[ Outside the chain picture transfer in …(img-QxmJ01nz-1628508921306)]