python生成验证码

import random

def Verifi_code():
    code = []
    for i in range(6):
        if i == random.randint(1,5):
            code.append(str(random.randint(1,5)))
        else:
            temp = random.randint(65,90)
            code.append(chr(temp))
    a = ''.join(code)
    return a

b = Verifi_code()

print b

 

posted @ 2017-03-25 11:52  aallennty  阅读(120)  评论(0编辑  收藏  举报