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)
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章