Generate Random Verification code

Source: Internet
Author: User

Generate Random Verification Code instances
Import Randoma=[]c="' forIinchRange6):    ifi = = Random.randrange (1,4): A.append (str (Random.randint (1,9)))    Else: Temp= Random.randint ( $, -) a.append (Chr (temp)) Print ab="".Join(a) print B forIinchA:c+=str (i) Print C

Output to

[' D ', ' J ', ' A ', ' 5 ', ' B ', ' P '] dja5bpdja5bp

——————— Knowledge Extension

1. chr (i),英文说明: returns the ASCII character corresponding to the integer i. Contrary to the Ord () effect.

2. Character stitching method comparison. The following are examples of time-consuming comparisons:

Import Cstringioimport Stringioimport TimeValues=[]items= ['1,2,31,2,31,2,31,2,3'] *10000000#print itemsst=float( Time. Time()) forIinchItems:values.append (i) News="'.Join(values) print len (news) Print'list Append cost time:%s'%(float( Time. Time()) -St) Strio=Cstringio.stringio () St=float( Time. Time()) forJinchItems:strio.Write(j) Print Len (Strio.getvalue ()) Print'Cstringio cost time:%s'%(float( Time. Time()) -St) Strio=Stringio.stringio () St=float( Time. Time()) forJinchItems:strio.Write(j) Print Len (Strio.getvalue ()) Print'Stringio cost time:%s'%(float( Time. Time())-ST)

Generate Random Verification code

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.