pyqrcode 二维码生成器

1. 介绍

The pyqrcode module is a QR code generator that is simple to use and written in pure python. 

2. 安装

   pip install pyqrcode

3. 简单演示代码

import pyqrcode
# a simple example of creating a QR code for a URL
url = pyqrcode.create("http://uca.edu")
# svg格式
url.svg("uca-url.svg", scale=8)
# EPS格式
url.eps("uca-url.eps", scale=2)
# terminal输出
print(url.terminal(quiet_zone=1))
import pyqrcode
big_code = pyqrcode.create("0987654321", error="L", version=27, mode="binary")
# create(content, error='H', version=None, mode=None, encoding=None)
# 返回一个QRCode实例对象
# error: sets the error correction level of the code  设置代码数据修正程度
# 一个有四种程度: "L", "M", "Q", "H"
# version ---> int (1-40)
# specifies the size and data capacity of the code  指定代码的大小和数据容量
# mode --->str
# specifies how the contents will be encoded. 指定代码内容使用什么编码格式
# "numeric", "alphanumeric", "kanji", "binary"
# encoding --->
# specifies how the content will be interpreted  指出内容将怎样解析
big_code.png("code.png", scale=6, module_color=[0,0,0,128],background=[0xff,0xff,0xcc])
big_code.show()

4. 官方文档

链接:https://pythonhosted.org/PyQRCode/

5. Rendering QR Codes

  1.  Text based rendering
  2. Terminal Rendering
  3. Image rendering
  4. XBMrendering
  5. SVG
  6. EPS
  7. PNG

6. 输出格式函数

  1.  eps(filescale=1module_color=(000)background=Nonequiet_zone=4)
  2.  png(filescale=1module_color=(000255)background=(255255255255)quiet_zone=4)
  3.  svg(filescale=1module_color='#000'background=Nonequiet_zone=4xmldecl=Truesvgns=Truetitle=Nonesvgclass='pyqrcode'lineclass='pyqrline'omithw=Falsedebug=False)

猜你喜欢

转载自blog.csdn.net/hello_dear_you/article/details/81205778