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

import pytesseract
from PIL import Image

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

 实际测试效果:

输入图片Python爬虫学习——光学字符识别,输出Python爬虫学习——光学字符识别,结果:成功

输入图片Python爬虫学习——光学字符识别,输出:为空,结果:失败

输入图片Python爬虫学习——光学字符识别,输出:为空,结果:失败

输入图片Python爬虫学习——光学字符识别,输出:Python爬虫学习——光学字符识别,结果:错误

相关文章:

  • 2022-12-23
  • 2021-12-06
  • 2021-12-06
  • 2021-11-28
  • 2021-12-16
  • 2021-04-30
  • 2021-11-18
  • 2021-03-30
猜你喜欢
  • 2022-12-23
  • 2021-12-06
  • 2021-09-20
  • 2021-11-13
  • 2021-05-20
  • 2021-12-26
相关资源
相似解决方案