from selenium import webdriver
import os
import pytesser
import sys,time
from PIL import Image,ImageEnhance

im = Image.open("G:\1.png")
imgry = im.convert('L') # 图像加强,二值化
sharpness = ImageEnhance.Contrast(imgry) # 对比度增强
sharp_img = sharpness.enhance(2.0)
sharp_img.save("G:\1.png")
code = pytesser.image_file_to_string("G:\1.png") # code 即为识别出的图片数字 str 类型
print(code)

网上搜来的代码,想套用
结果在使用过程中报错
C:\Python34\python.exe "C:/Users/dell/PycharmProjects/practice/.idea/inspectionProfiles/verification code.py"
Traceback (most recent call last):
File "C:/Users/dell/PycharmProjects/practice/.idea/inspectionProfiles/verification code.py", line 17, in
code = pytesser.image_file_to_string("G:\1.png") # code 即为识别出的图片数字 str 类型
AttributeError: 'module' object has no attribute 'image_file_to_string'

Process finished with exit code 1
有没有做过类似东西的老师,求指教


↙↙↙阅读原文可查看相关链接,并与作者交流