'''
import random
#1.随机数输出
print(random.random()) # 0-1随机浮点数
print(random.randint(1, 3)) # 范围整型随机一个(1,2,3)
print(random.randrange(1, 3)) # 范围整型随机一个(1,2)
print(random.choice(["a", "b", "c"])) # 多个元素选一个
print(random.sample(["a", "b", "c"], 2)) # 多个元素选多个
=============================
#2.将列表里的数据随机排序输出
l = [1, 2, 3, 4, 5, 6]
random.shuffle(l)
print(l) #随机排序输出
=============================
#3.构建5位验证码
print(ord("a")) #97
print(ord("b")) #98
print(ord("z")) #122
print(chr(97)) # a
print(chr(122)) # z
def get_random_str():
ret = []
for i in range(5):
random_num = str(random.randint(0, 9))
random_lower = chr(random.randint(97, 122))
random_upper = chr(random.randint(65, 90))
random_char = random.choice([random_num, random_upper, random_lower])
ret.append(random_char)
#print(ret) #列表输出['4', '1', '6', 'a', 'Y']
print("".join(ret)) #字符串输出416aY
return "".join(ret)
get_random_str()
=============================
'''