python 验证码

python写的验证码小程序

##################验证码,数字+字母
import random
check_code=""
for i in range(6):
    code_number = random.randint(0,9)
    if random.randint(0,1) == 0:
        codestr_number = random.randint(65,90)
        codestr_number = chr(codestr_number)
        check_code = check_code + str(codestr_number)
    else:
        check_code = check_code + str(code_number)
print (check_code)



##################验证码数字
import random
check_code=""
for i in range(6):
    code_number = random.randint(0,9)
    check_code = check_code + str(code_number)
print (check_code)

  

posted @ 2016-12-07 22:18  Tony_Deng  阅读(348)  评论(0编辑  收藏  举报