python写的一个验证码小程序

 

 __author__ = 'ley'
#导入random模块
import random

checkcode=''
for i in range(4):
    #print(i)
    current=random.randrange(0,4)
    #print(current)
    if current !=i:
    #chr65-90为:A-Z字符
        temp=chr(random.randint(65,90))
        #print(temp)
    else:
        temp=random.randint(0,9)
        #print(temp)
    checkcode+=str(temp)
print(checkcode)

你可能感兴趣的:(code,python,Random)