import random
digits = [chr(i) for i in range(48, 58)]
letters = [chr(i) for i in range(65, 91)] + [chr(i) for i in range(97, 123)]
number_of_digits = random.randint(1, 7)
number_of_letters = 8 - number_of_digits
randdigits = [random.choice(digits) for i in range(number_of_digits)]
randletters = [random.choice(letters) for i in range(number_of_letters)]
randdigits.extend(randletters)
random.shuffle(randdigits)
print(''.join(randdigits))
python随机产生8位密码,密码由数字和字母组成
最新推荐文章于 2024-09-08 16:16:59 发布