Randomly generated six-bit code function version (Python)

Source: Internet
Author: User

ImportRandomdefCode (n=6,alpha=True): s="' #Create a string variable to store the generated verification code     forIinchRange (N):#Verify the number of code bits with a for loop controlnum = Random.randint (0,9)#generate random number 0-9        ifAlpha#requires the letter verification code, does not have the argument, if does not need the letter, the keyword Alpha=falseUpper_alpha = Chr (Random.randint (65,90)) Lower_alpha= Chr (Random.randint (97,122) Num=Random.choice ([Num,upper_alpha,lower_alpha]) s= S +str (num)returnsPrint(Code (6,FALSE))#Print 6 digit verification CodePrint(Code (6,TRUE))#Print 6-digit mixed-letter verification CodePrint(Code (4,FALSE))#Print 4 digit verification CodePrint(Code (4,TRUE))#Print 4-digit mixed-letter verification Code

The above code for reference only, there are questions can leave a message, communicate with each other!

Randomly generated six-bit code function version (Python)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.