以下为python识别二维码的代码,安装好模块后传入图片路径就行
import os
import qrcode
from PIL import Image
from pyzbar import pyzbar
def decode_qr_code(code_img_path):
if not os.path.exists(code_img_path):
raise FileExistsError(code_img_path)
# Here, set only recognize QR Code and ignore other type of code
return pyzbar.decode(Image.open(code_img_path), symbols=[pyzbar.ZBarSymbol.QRCODE])