python--随机验证码

def check_code():
    import random
    checkcode = ''
    for i in range(6):
        current = random.randrange(0,6)
        if current != i:
            temp = chr(random.randrange(65,90))
        else:
            temp = random.randrange(0,9)
        checkcode += str(temp)
    return checkcode
code = check_code()
print(code)

猜你喜欢

转载自www.cnblogs.com/Essaycode/p/10063041.html