使用pytesseract库对图片文件(jpg、png、bmp等)进行识别,把图片转换成字符串输出。
import pytesseract from PIL import Image img = Image.open('1.gif') print pytesseract.image_to_string(img)
实际测试效果:
输入图片,输出,结果:成功
输入图片,输出:为空,结果:失败
输入图片,输出:为空,结果:失败
输入图片,输出:,结果:错误
使用pytesseract库对图片文件(jpg、png、bmp等)进行识别,把图片转换成字符串输出。
import pytesseract from PIL import Image img = Image.open('1.gif') print pytesseract.image_to_string(img)
实际测试效果:
输入图片,输出,结果:成功
输入图片,输出:为空,结果:失败
输入图片,输出:为空,结果:失败
输入图片,输出:,结果:错误