python使用 pytesseract + tesseract-ocr 进行验证码识别
使用 pytesseract + tesseract-ocr 进行验证码识别,需要安装的第三方库:pytesseract 、tesseract-ocr,在使用pytesseract 之前,必须安装tesseract-ocr,因为 pytesseract 依赖于tesseract-ocr,否则无法使用。
1、tesseract-ocr下载安装与配置:tesseract-ocr下载安装与配置
2、pytesseract 安装:pip install pytesseract
3、修改pytesseract.py脚本
在python的安装目录下找到pytesseract 的安装路径,在pytesseract 文件夹下的pytesseract.py脚本中,用记事本打开pytesseract.py,通过ctrl+f快速搜索功能定位tesseract_cmd,修改后面的文件路径。
4、用pytesseract识别验证码
1 2 3 4 5 6 7 8 9 10 | from PIL import Image import pytesseract # 用pytesseract识别验证码 # 1:打开需要识别的图片 image = Image. open (r 'image\code.png' ) # 2:pytesseract识别为字符串 code = pytesseract.image_to_string(image) # 3:输出识别的内容 print (code) |
分类:
Python相关
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· Manus重磅发布:全球首款通用AI代理技术深度解析与实战指南
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
· 没有Manus邀请码?试试免邀请码的MGX或者开源的OpenManus吧
· 园子的第一款AI主题卫衣上架——"HELLO! HOW CAN I ASSIST YOU TODAY
· 【自荐】一款简洁、开源的在线白板工具 Drawnix
2021-03-18 vue动态配置参数,避免重复打包
2021-03-18 export报错SyntaxError: Unexpected token export
2021-03-18 windows下安装和配置Redis
2020-03-18 工具连接