Python-生成随机验证码

import random

##生成随机验证码

def make_code(n):
    res = ''
    for i in range(n):
        current = random.randint(0,n)
        if current == i:
            tmp = chr(random.randint(65,90))
        else:
            tmp = random.randint(0,9)
        res += str(tmp)
    print(res)

make_code(5)
原文地址:https://www.cnblogs.com/Xuuuuuu/p/9490285.html