This article mainly introduces the Python verification code recognition method, which involves Python's analysis and operation skills on verification code images. it has some reference value, for more information about how to identify Python verification codes, see the following example. Share it with you for your reference. The specific implementation method is as follows:
# Encoding = utf-8import Image, ImageEnhance, ImageFilterimport sysimage_name = ". /22.jpeg "# interference point im = Image. open (image_name) im = im. filter (ImageFilter. medianFilter () enhancer = ImageEnhance. contrast (im) im = enhancer. enhance (2) im = im. convert ('1') # im. show () # Test View s = 12 # start cutting point xt = 2 # start cutting point yw = 10 # cut width + yh = 15 # cut length + xim_new = [] for I in range (4): # verification code cut im1 = im. crop (s + w * I + I * 2, t, s + w * (I + 1) + I * 2, h) im_new.append (im1) # im_new [0]. show () # Test xsize, ysize = im_new [0]. sizegd = [] for I in range (ysize): tmp = [] for j in range (xsize): if (im_new [0]. getpixel (j, I) = 255): tmp. append (1) else: tmp. append (0) gd. append (tmp) # View results for I in range (ysize): print gd [I]
I hope this article will help you with Python programming.