在python中使用pytesseract模块实现一个图像识别,具体方法如下:
import pytesseract #导入pytesseract模块
from PIL import Image
class GetImageDate(object):
def m(self):
image = Image.open(u"a.png")
text = pytesseract.image_to_string(image)
return text
def SaveResultToDocument(self):
text = self.m()
f = open(u"Verification.txt","w")
print text
f.write(str(text))
f.close()
g = GetImageDate()
g.SaveResultToDocument()