## random随机 print(random.random())##随机浮点数0-1 print(random.randint(1,2))###随机整数,包括前和后 print(random.randrange(0,13))###随机整数,包前不包尾 print(random.uniform(1,10))###随机1-10的浮点数 print(random.choices("fiuadfffd"))##随机字符 print(random.sample("caizhonge",3))##随机从字符串中选取特定数量的字符 print(random.choice(["apple","per","cia","ca"]))##随机选取字符串 ##洗牌 ir = [1,2,3,4,5,6,7,8] random.shuffle(ir) print(ir)
##验证码 T=random.sample("qwertyuioplkjhgfdsazxcvbnmQWERTYUIOPLKJHGFDSAZMNBVCX0123456789",4) coa = "" for i in T: coa += str(i) print(coa)