随机发送n位数字+字母的验证码

'''
随机发送n位数字+字母的验证码
'''

import random


def get_verified(length):
    code = ''
    for i in range(length):
        num = str(random.randint(0, 9))
        ALP = chr(random.randint(65, 90))
        alp = chr(random.randint(97, 122))
        res = random.choice((num, ALP, alp))
        code += res

    return code

res = get_verified(5)
print(res)
原文地址:https://www.cnblogs.com/jinhongquan/p/11359791.html