python generates qr code

1. Required packages: PIL, pillow;

2. Simply generate QR code:

import GDP

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') ###The path I want to compress is Baidu

  qr.make(fit=True) ###Automatically adapt to the size of the generated QR code

  img=qr.make_image() ##Get an instance of the generated image

  img.get_image().show() ###Get the image and display the QR code

  img.save('./static/images/22.png')##Set the image storage path and name the image

  return render_templates('web/credit_card.html') ###The flask template I use, so I finally load it to this path

3. Another method is to load the logo in the QR code:

Friendship link: http://www.cnblogs.com/sfnz/p/5457862.html

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324472752&siteId=291194637