# 随机模块
import random
# print(random.randint(1,6)) # 1 # 随机取一个你提供的整数范围内的数字  包含首尾
# print(random.random()) # 0.2636316825914742 #  # 随机取0-1之间小数
# print(random.choice([1,2,3,4,5,6])) # 摇号 随机从列表中取一个元素
# res = [1,2,3,4,5,6]
# random.shuffle(res)  # 洗牌
# print(random.choice([1,2,3,4,5,6]))# 摇号 随机从列表中取一个元素
# res = [1,2,3,4,5,6]
# random.shuffle(res)  # 洗牌
# print(res)
# 生成随机验证码
"""
大写字母 小写字母 数字
5位数的随机验证码
chr
random.choice
封装成一个函数,用户想生成几位就生成几位
"""
def get_code(n):
    code = ''
    for i in range(n):
        # # 先生成随机的大写字母 小写字母 数字
        upper_str = chr(random.randint(65,90))
        lower_str = chr(random.randint(97,122))
        random_int = str(random.randint(0,9))
        # 从上面三个钟随机选择一个作为随机验证码的某一位
        code += random.choice([upper_str,lower_str,random_int])
    return code
res = get_code(4) # OYwJ
print(res)