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)
  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值