怎么识别二维码

  1. 安装第三方库
    下载 pyzbar 库并安装,
    点击下载第三方库 pyzbar-0.1.7-py2.py3-none-win32.whl
    安装方式请参考下面:
    http://support.i-search.com.cn/article/1530238153623

  2. 代码:
    import pyzbar.pyzbar as pyzbar
    from PIL import Image

def QR_code(imgpath):

# 读取图片
imgpath=imgpath
img = Image.open(imgpath).convert('L')
barcodes = pyzbar.decode(img)
qr_codes=''
for barcode in barcodes:
    barcodeData = barcode.data.decode("utf-8")
    qr_codes+=barcodeData
if qr_codes != '':
    print('识别成功:'+qr_codes)
    return True,qr_codes
else:
    print('识别失败')
    return False,''

pyzbar