Random module (captcha applet)

Source: Internet
Author: User

 #  !/usr/bin/env python  #  -*-coding:utf-8-*- import  Span style= "color: #000000;" > Randomli  =[]  for  i in  Range (6): #   loop a few times, just Represents the generation of several verification codes  num = Random.randrange (65,95) #  65-91 random Print Range, (65<=num<91)  c=CHR (num) li.append (c) Result  = "" . Join (LI) #   The meta in the list Must be a string  print  (Result) 
#生成的验证码第二位和第四位是数字
li1=[] forIinchRange (6):    ifi = = 2ori = = 4:#here is the definition of locationnum = Random.randrange (0,10) li1.append (num)#because the join concatenation must be a string, the conversion is done here    Else: Num1= Random.randrange (65,91) C=CHR (NUM1)#chr () function function: Converts a number to a letterLi1.append (c) RET="". Join (LI1)Print(ret)
#随机生成数字和字母
#!/usr/bin/env python#-*-coding:utf-8-*-ImportRandomli2=[] forIinchRange (6): num2=random.randrange (0,5)    ifnum2 = = 2ornum2 = = 4:#This is defined as a location.num = Random.randrange (0,10) li2.append (num)#because the join concatenation must be a string, the conversion is done here    Else: Num1= Random.randrange (65,91) C=chr (NUM1) Li2.append (c) RET="". Join (LI2)Print(ret)

Random module (captcha applet)

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.