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())

原文地址:https://www.cnblogs.com/c-x-a/p/10419189.html