设为首页 加入收藏

TOP

关于多种验证码的应对方式(二)
2023-07-25 21:23:21 】 浏览:43
Tags:关于多 应对方
f ocr_detect(path): """ OCR汉字识别 """ fp, code = None, None if not os.path.exists(path): return code _, file_type = path.rsplit(".",1) if file_type.lower() not in ALLOW_FILE_TYPE: return code try: fp = open(path, 'rb') con1 = fp.read() img = Image.open(BytesIO(con1)) code = ocr.classification(img) except Exception as exc: print('[ERROR] 识别发生错误:', exc) finally: if fp: fp.close() return code if __name__ == '__main__': code = ocr_detect(r'E:\pic\123\test.jpg') for i in range(8): code2 = ocr_detect(f'E:\pic/123/{i}.jpg') if code == code2: print(f"编码为{i}的是对的") else: print("寄了")

具体使用方式参考官方文档即可

更多方法用到后会继续更新~

首页 上一页 1 2 下一页 尾页 2/2/2
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇Python模块:subprocess模块教程 下一篇重温Python基础——字符串

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目