Generate QR code in Python

Time:2022-5-6

This paper introduces the basic use of a QR code library that can be associated. Myqr (amzqr) is very convenient to use

Myqr (amzqr) library

You can generate ordinary QR code, art QR code (black and white or color), and animation QR code (black and white or color).

At present, the official website seems to be renamed:amzqr

However, the use method has not changed. I still recommend the latest version later

Official website parameters

terminal:

myqr words
[-h]
[-v {1,2,3,...,40}]
[-l {L, M, Q, H}]
[-p image_filename]
[-c]
[-con contrast_value]
[-bri brightness_value]
[-n output_filename]
[-d output_directory]

import:

from MyQR import myqr
version, level, qr_name = myqr.run(
words,
version = 1,
level = 'H',
picture = None,
colorized = False,
contrast = 1.0,
brightness = 1.0,
save_name = None,
save_dir = os.getcwd()
)

Use example:

#!/usr/bin/env python
# _*_ coding: utf-8 _*_

# MyQR
from MyQR import myqr

#Generate ordinary QR code
myqr.run(words="https://www.cnblogs.com/wylshkjj/", version=9,
         save_name="website.png",
         save_dir="createQR"
         )

#Generate QR code with graph
myqr.run(words="https://www.cnblogs.com/wylshkjj/", version=9,
         picture=r"F:\Workspoace\PyWorkwm\image\test-JPEG.jpg",
         colorized=True,
         save_name="website2.png",
         save_dir="createQR"
         )

#Two dimensional code for generating GIF dynamic graph
myqr. run(words=" https://www.cnblogs.com/wylshkjj/ ", version = 9, # content
         Picture = R "F: \ workspool \ pywork \ 2wm \ image \ test GIF. GIF", # background picture, file path needs to be set
         Colored = true, # background color, default false black and white
         Level ='h ', # error correction level, default h is the highest
         Contrast = 1.0, # contrast. The default is 1.0. The larger the, the higher
         Brightness = 1.0, # brightness. The default value is 1.0. The higher the brightness, the higher the brightness
         save_ Name = "website3. GIF", # save file name format, default to project png
         save_ Dir = "createqr", # save path is the working path of the program
         )

# amzqr
from amzqr import amzqr

#Generate ordinary QR code
amzqr.run(words="https://www.cnblogs.com/wylshkjj/", version=9,
         save_name="website.png",
         save_dir="createQR"
         )

#Generate QR code with graph
amzqr.run(words="https://www.cnblogs.com/wylshkjj/", version=9,
         picture=r"F:\Workspoace\PyWorkwm\image\test-JPEG.jpg",
         colorized=True,
         save_name="website2.png",
         save_dir="createQR"
         )

#Two dimensional code for generating GIF dynamic graph
amzqr. run(words=" https://www.cnblogs.com/wylshkjj/ ", version = 9, # content
         Picture = R "F: \ workspool \ pywork \ 2wm \ image \ test GIF. GIF", # background picture, file path needs to be set
         Colored = true, # background color, default false black and white
         Level ='h ', # error correction level, default h is the highest
         Contrast = 1.0, # contrast. The default is 1.0. The larger the, the higher
         Brightness = 1.0, # brightness. The default value is 1.0. The higher the brightness, the higher the brightness
         save_ Name = "website3. GIF", # save file name format, default to project png
         save_ Dir = "createqr", # save path is the working path of the program
         )