我的知识记录

Python 识别二维码内容:批量读取二维码

import os
from pyzbar.pyzbar import decode
from PIL import Image
 
def decode_qrcodes(folder):
    for name in os.listdir(folder):
        if not name.lower().endswith(('.png', '.jpg', '.jpeg')):
            continue
        path = os.path.join(folder, name)
        result = decode(Image.open(path))
        for r in result:
            print(f"{name} -> {r.data.decode('utf-8')}")
 
decode_qrcodes('./qrcodes')

Python 识别二维码内容:批量读取二维码

标签:

更新时间:2026-09-14 13:34:57

上一篇:Python 批量生成二维码:带 Logo 的漂亮二维码

下一篇:Python 网页截图:批量给网页截图保存