mac使用pytesseract

import locale
locale.setlocale(locale.LC_ALL, 'C')
import pytesseract
import pathlib
import traceback
from PIL import Image
file_path = str(pathlib.Path.cwd().joinpath("picture/3.jpg"))
img = Image.open(file_path) #先创建image对象
try:
   text = pytesseract.image_to_string(img,lang="eng") #直接转化成string,更多参数可以查看文档

   print(text)
except:
    print(traceback.format_exc())

posted @ 2019-02-22 16:33  公众号python学习开发  阅读(599)  评论(0编辑  收藏  举报