python 生成二維碼


1、需要以來的包:PIL、pillow;

2、簡單生二維碼:

import PIL

from pillow import Image

def GetImage():

  qr = qrcode.QRCode(version=None, error_correction=qrcode.constants.ERROR_CORRECT_L, box_size=10, border=1,)

  qe.add_data('https://www.baidu.com')  ###我要壓縮的路徑為百度

  qr.make(fit=True)  ###自動適應生成的二維碼大小

  img=qr.make_image()  ##獲得生成圖片的實例

  img.get_image().show()  ###獲得圖片並且顯示二維碼

  img.save('./static/images/22.png')##設置圖片存儲路徑並且命名圖像

  return render_templates('web/credit_card.html')  ###我用的flask模版,所以最后加載到此路徑

3、還有一個是在二維碼里面加載logo的方法:

友情鏈接:http://www.cnblogs.com/sfnz/p/5457862.html


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM