python-验证码图片识别

import tesserocr
from PIL import Image

#新建Image对象
image = Image.open('code.png')
#调用tesserocr的image_to_text()方法,传入image对象完成识别
result = tesserocr.image_to_text(image)
print(result)
a=''
for line in result:
  if line.split():
    line = line.rstrip()
    a=a+line
print(a)



# if result == '4VC7':
#     print('true')
# else:
#     print('false')
posted @ 2020-07-06 19:24  renblog  阅读(239)  评论(0编辑  收藏  举报