基本信息
源码名称:识别图片中的二维码存入表格
源码大小:1.36KB
文件格式:.py
开发语言:Python
更新时间:2025-04-05
友情提示:(无需注册或充值,赞助后即可获取资源下载链接)
嘿,亲!知识可是无价之宝呢,但咱这精心整理的资料也耗费了不少心血呀。小小地破费一下,绝对物超所值哦!如有下载和支付问题,请联系我们QQ(微信同号):813200300
本次赞助数额为: 10 元×
微信扫码支付:10 元
×
请留下您的邮箱,我们将在2小时内将文件发到您的邮箱
源码介绍
:指定文件夹内的图片,如果含有二维码识别 并保存在表格中,多线程2000/秒数据
配置项
FOLDER_PATH = Path(r"D:\pythonProject\pythonProject3\zp")
OUTPUT_EXCEL = "output_20250.xlsx"
IGNORE_PREFIXES = ("69", "http", "HTTP", "Http")
SUPPORTED_IMAGES = frozenset({'.png', '.jpg', '.jpeg', '.bmp', '.gif'})
processed_codes: Set[bytes] = set()
processed_lock = Lock()
def extract_info(txt_content: str) -> Tuple[str, str, str]:
"""从txt内容中提取姓名、地址、电话"""
name_match = re.search(r'姓名\s*=\s*([^,] )', txt_content)
address_match = re.search(r'地址\s*=\s*([^,] )', txt_content)
phone_match = re.search(r'电话\s*=\s*([^,] )', txt_content)
name = name_match.group(1).strip() if name_match else "没有姓名记录"
address = address_match.group(1).strip() if address_match else "没有地址记录"
phone = phone_match.group(1).strip() if phone_match else "没有电话记录"
print(name)
return name, address, phone
def process_image(file_path: Path, name: str, address: str, phone: str) -> List[Tuple[str, str, str, str]]:
# 优化解码逻辑,减少重复解码和异常处理开销
qr_contents = []
try:
img = Image.open(file_path)
codes = decode(img)
for code in codes:
qr_content = decode_qr_content(code.data) # 直接传递data以减少函数调用开销
:指定文件夹内的图片,如果含有二维码识别 并保存在表格中,多线程2000/秒数据
配置项
FOLDER_PATH = Path(r"D:\pythonProject\pythonProject3\zp")
OUTPUT_EXCEL = "output_20250.xlsx"
IGNORE_PREFIXES = ("69", "http", "HTTP", "Http")
SUPPORTED_IMAGES = frozenset({'.png', '.jpg', '.jpeg', '.bmp', '.gif'})
processed_codes: Set[bytes] = set()
processed_lock = Lock()
def extract_info(txt_content: str) -> Tuple[str, str, str]:
"""从txt内容中提取姓名、地址、电话"""
name_match = re.search(r'姓名\s*=\s*([^,] )', txt_content)
address_match = re.search(r'地址\s*=\s*([^,] )', txt_content)
phone_match = re.search(r'电话\s*=\s*([^,] )', txt_content)
name = name_match.group(1).strip() if name_match else "没有姓名记录"
address = address_match.group(1).strip() if address_match else "没有地址记录"
phone = phone_match.group(1).strip() if phone_match else "没有电话记录"
print(name)
return name, address, phone
def process_image(file_path: Path, name: str, address: str, phone: str) -> List[Tuple[str, str, str, str]]:
# 优化解码逻辑,减少重复解码和异常处理开销
qr_contents = []
try:
img = Image.open(file_path)
codes = decode(img)
for code in codes:
qr_content = decode_qr_content(code.data) # 直接传递data以减少函数调用开销