原文地址:http://www.cnblogs.com/tanghuang/p/6380588.html
适用版本:python2以下
将图片中的数字通过 pytesseract.image_to_string(image)
识别后将结果存入到本地的txt文件中
1 #-*-encoding:utf-8-*-
2 import pytesseract
3 from PIL import Image
4
5 class GetImageDate(object):
6 def m(self):
7 image = Image.open(u"C:\\a.png")
8 text = pytesseract.image_to_string(image)
9 return text
10
11 def SaveResultToDocument(self):
12 text = self.m()
13 f = open(u"C:\\Verification.txt","w")
14 print text
15 f.write(str(text))
16 f.close()
17
18 g = GetImageDate()
19 g.SaveResultToDocument()
转载于:https://www.cnblogs.com/mufenglin/p/7477708.html