在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()
辰迅云「云服务器」,即开即用、新一代英特尔至强铂金CPU、三副本存储NVMe SSD云盘,价格低至29元/月。点击查看>>
推荐阅读: python如何创建新文件