Pytesseract图片识别结果箭头符号去除

it2025-09-09  7

在使用pytesseract模块的image_to_string()功能时,识别出的结果总是带有这个向上的箭头 和很多的换行符,在0.3.5/0.3.6版本均有多余箭头问题.

只要使用.strip()移除字符串头尾指定的字符(默认为空格或换行符)或字符序列代码如下:

import os import sys import pytesseract from PIL import Image def ocrx(image_name,lang_name): # open image image = Image.open(image_name) code = pytesseract.image_to_string(image, lang=lang_name)#选择语言库 code = code.strip() #print(code) return code Result = ocrx("G0.jpg",'eng') print(Result)

待识别的图片G0.jpg

执行结果如下:

最新回复(0)