python pytesseract——3步识别验证码的识别入门

验证码识别是个大工程,但入门开始只要3步。需要用到的库PIL、pytesserac,没有的话pip安装。还有一个是tesseract-ocr 下载地址:https://sourceforge.net/projects/tesseract-ocr-alt/files/。

哪3步?

 

1、安装库

pip install Pillow
pip install pytesseract

 

2、安装tesseract-ocr

默认安装,主要是新添加个环境变量。如下图

 

3、编写代码

import pytesseract 
from PIL import Image
print pytesseract.image_to_string(Image.open("D:\\Desktop\\1.png"),lang="eng",config="-psm 7")

 

举个例子,上图的识别

 

 

bingo,7572!

 

posted on 2018-02-04 19:08  vhills  阅读(4387)  评论(2编辑  收藏  举报