1.安装 Python图像处理库 PIL 网上有下载的:PIL-1.1.7.win32-py2.7.exe
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
但是呢 主要还是简单的验证码可以识别。