Python爬虫学习——光学字符识别

使用pytesseract库图片文件(jpg、png、bmp等)进行识别,把图片转换成字符串输出。

import pytesseract
from PIL import Image

img = Image.open('1.gif')
print pytesseract.image_to_string(img)

 实际测试效果:

输入图片,输出,结果:成功

输入图片,输出:为空,结果:失败

输入图片,输出:为空,结果:失败

输入图片,输出:,结果:错误

原文地址:https://www.cnblogs.com/tonglin0325/p/6280344.html