【发布时间】:2020-11-17 14:44:55
【问题描述】:
我目前在 Windows 10 上通过 anaconda 和 python 3.8.5 使用 spyder,当我运行此代码时:
import cv2
import pytesseract
pytesseract.pytesseract.tesseract_cmd = r"C:\\Program Files\\Tesseract-OCR\\tesseract.exe"
img_path ='img/gotta-go-fast.jpg'
img = cv2.imread(img_path)
img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)
result = pytesseract.image_to_string(img, lang='eng')
print(result)
spyder 中的 IPython 控制台会自动被清除,但如果我只写入这样的文本文档,则不会发生同样的情况:
result = pytesseract.image_to_string(img, lang='eng')
with open('text_result.txt', mode ='w') as file:
file.write(result)
有没有办法解决这个问题?
【问题讨论】:
标签: python anaconda spyder tesseract python-tesseract