It can be made simply by python random number codes.
1.0 versions, and this code, only one code, although not up to function, logic, or accurate, we can not be considered a verification code, but we will continue to improve.
Import Random # introducing a random number function Random checkcode = '' # set a variable empty, as codes for I in Range (. 4): # cycle numbers between 0. 4 checkcode = + STR (I) # each string into digital Print (checkcode) # output out
The result: 0123 (each time the fixed numbers) Oh
Version 1.1 came, we use a random number, plus a random code can be generated.
Import Random # introducing a random number function Random checkcode = '' # set a variable empty, as codes for i in range(4): Current = the random.randint (0,9) # of each cycle a random number it checkcode = + STR (Current) Print (checkcode) # output out
The result: a four-digit code 6151 was born.
? Version 1.2 came, the students said pure digital so do not fly, the level is too low, insecurity, you can not add the letter I said: Well that is not simple, add the letter is not on the list thing.
# The Author: Dwdar Import Random # introducing a random number function Random checkcode = '' # set a variable empty, as codes for i in the Range (4 ): # adding the letter Current random.randrange = (0, 4) # guess, I generated random number and i will not be equal to it? IF Current I ==: # If guessed temp = CHR (the random.randint (65, 90)) # then identify any input ASCII codes, converting it to put letters temp saved. # Add digital the else : temp = the random.randint (0,. 9) # If there is no knife, it is the original number between 0 to 9, temp kept up into checkcode = + STR (temp) # to keep up with them can generate temp a combination of numbers or letters of the set of data. print(checkcode)
The results are: 24G4, may generate a combination of letters and numbers (sometimes pure digital and pure letters), and relatively good instrument allows to verify the code. If you want to make a six-figure, as long as the two 4-6 can be changed.
1.3 versions, the 6-digit alphanumeric combination codes.
# The Author: Dwdar Import Random # introducing a random number function Random checkcode = '' # set a variable empty, as codes for i in the Range (6 ): # adding the letter Current random.randrange = (0, 6) # guess, I generated random number and i will not be equal to it? IF Current I ==: # If guessed temp = CHR (the random.randint (65, 90)) # then identify any input ASCII codes, converting it to put letters temp saved. # Add digital the else : temp = the random.randint (0,. 9) # If there is no knife, it is the original number between 0 to 9, temp kept up into checkcode = + STR (temp) # to keep up with them can generate temp a combination of numbers or letters of the set of data. print(checkcode)
The result: 889 152