The verification code generating captcha python

captcha word is not a word but a string of abbreviations  Completely Automated Public Turing Test to Tell Computers and Humans Apart ( automatic distinction between computer and human Turing test) . We all know what the Turing test is, captcha core idea is to design a human can easily pass but the computer can not complete the task, the task of the test results to determine operate in the end is a human or a computer.

 

Codes generated code is as follows:

from captcha.image import ImageCaptcha
import matplotlib.pyplot as plt
import numpy as np
import random
import string

characters = string.digits + string.ascii_lowercase
print(characters)

width, height, n_len, n_class = 170, 80, 4, len(characters)

generator = ImageCaptcha(width=width, height=height)
random_str = ''.join([random.choice(characters) for j in range(4)])
img = generator.create_captcha_image(random_str, (0, 0, 153), (255, 255, 255))
img.save("generate.png")
img.show()
plt.imshow(img)
plt.title(random_str)

But the school's website and want to generate similar code with the code, but found that it seems to be some problems, because I found the time to re-transmission of color parameter is not accurate, I pass the code after the color (0,0,153) I was not obtained to the blue, the color looked method is to use an example (255,255,255), it still does not get to the bottom, and direct access to their own school code data under their own hand washing, lay the label forget their own training.

Guess you like

Origin www.cnblogs.com/gwklan/p/11305724.html