Python简单的验证码识别

1.安装 Python图像处理库 PIL     网上有下载的:PIL-1.1.7.win32-py2.7.exe


2.安装 tesseract-ocr :google的ocr识别引擎。下载


3.安装 pytesseract 

直接使用pip install pytesseract安装

接着编写xx.py:
try:
    import pytesseract
    from PIL import Image
except ImportError:
    raise SystemExit

image = Image.open('captcha.png')
captcha = pytesseract.image_to_string(image)
print captcha
结果:


若是出现:
AttributeError: ‘NoneType’ object has no attribute ‘bands’
请进入D:\Python2.7\Lib\site-packages\PIL\Image.py 在1501行 改成:
def split(self):
1495         "Split image into bands"
1496 
1497         self.load()
1498         if self.im.bands == 1:
1499             ims = [self.copy()]
1500         else:
1501             #self.load()
1502             ims = [] 
1503             for i in range(self.im.bands):
1504                 ims.append(self._new(self.im.getband(i)))
1505         return tuple(ims)
ok。
参考 www.waitalone.com
但是呢   主要还是简单的验证码可以识别。

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值