今天复习到了random,写了一个验证码(4位)
import random
random_letter_upper = chr(random.randrange(97,122)).upper()
random_letterlower = chr(random.randrange(97,122)).lower()
random_num1 = random.randrange(0,10)
random_num2 = random.randrange(0,10)
list = [random_num1,random_letter_upper,random_letterlower,random_num2]
# print(list[random.randint(0,3)],list[random.randint(0,3)],list[random.randint(0,3)],list[random.randint(0,3)])#这是第一种输出,感觉不太对,数字会出现相同,
# print(random.sample(list,k = 1),random.sample(list,k = 1),random.sample(list,k = 1),random.sample(list,k = 1))#这个偶尔出现相同
print(random.sample(list,k = 4))#这是目前最好的
这个是结果