用于生成4位随机验证码
#_*_coding:utf-8_*_ #__author__ = "csy" import random checkcode=‘‘ for i in range(4): current=random.randrange(0,4) #生成随机数与循环次数比对 current1 = random.randrange(0,4) if current == i: tmp=chr(random.randint(65,90)) #65~90为ASCii码表A~Z elif current1 == i: tmp = chr(random.randint(97,122)) #97~122为ASCii码表a~z else: tmp=random.randint(0,9) checkcode+=str(tmp) print(checkcode)
原文:http://www.cnblogs.com/csy113/p/7191263.html