Python Verification code 6-bit Auto generator
! /usr/bin/env python#-*-coding:utf-8-*- ImportRandom tem="" forIinchRange (6): Digi= Random.randrange (0,11) ifDigi = = 1orDigi = = 5:## # # #当randrange (0,11) randomly generated number is 1 or 5 when,,,,:) is not a bit around Ah, hahahanum = Random.randrange (1,10) Num=str (num) TEM+=NumElse: ZM= Random.randrange (65,91) ZM=chr (ZM) TEM+=ZMPrint(TEM)
Note
#注: The greater the number of Digi, the less the chance of the IF, the smaller the number of digits that can be obtained.
#循环6次
The #定义空字符串 is to put the generated captcha characters and output them
#random () returns a randomly generated number corresponding to the ASCII code table
#chr () is the use of the ASCII Code table conversion, and Ord is the opposite
int (x [, Base]) converts x to an integer long (x [, Base]) converts X to a long integer, float (x) converts x to a floating-point number complex (real [, IMAG]) create a complex str (x) to convert object x to String repr (x) to convert object x to expression string eval (str) Used to calculate a valid Python expression in a string, and returns an object tuple (s) converts the sequence s to a tuple list (s) to convert the sequence s to a listing chr (x) Converts an integer to a character UNICHR (x) converts an integer to a Unicode character, Ord (x) converts a character to its integer value, hex (x) Converts an integer to a hexadecimal string Oct (x)
Python Verification code 6-bit Auto generator