Python 验证码识别(别干坏事哦...)

关于python验证码识别库,网上主要介绍的为pytesser及pytesseract,其实pytesser的安装有一点点麻烦,所以这里我不考虑,直接使用后一种库。

python验证码识别库安装

要安装pytesseract库,必须先安装其依赖的PIL及tesseract-ocr,其中PIL为图像处理库,而后面的tesseract-ocr则为google的ocr识别引擎。

1、Pillow 下载地址:[下载]

3.4中只能使用pillow,使用方法基本和PIL没有什么区别。

2、tesseract-ocr下载地址:[下载]

这货在安装过程中比较慢,耐心一点。

3、pytesseract安装

直接使用pip install pytesseract安装即可,或者使用easy_install pytesseract

 

Python验证码识别代码:[太简单了]

import pytesseract

from PIL import Image

image = Image.open('vcode.png')

vcode = pytesseract.image_to_string(image)

print (vcode)

   

识别率还挺高的,当然这也和验证码本身有关,因为这个验证码设计的比较容易识别,别用来干坏事哦

可惜CMD调用中文识别成这鸟样了,以后再研究:

 

原文地址:https://www.cnblogs.com/yeayee/p/4955506.html