import random
lower='abcdefghijklmnopqrstuvwxyz' # 小写字母
upper='ABCDEFGHIJKLMNOPQRSTUVWXYZ' # 大写字母
digits='0123456789' # 数字
symbols='~!@#$%^&*' # 符号
# 拼接所有字符
all = lower + upper + digits + symbols
print("欢迎使用密码生成器!")
length = int(input("请输入您希望生成的密码长度: "))
# 随机选择字符
password = ''
for i in range(length):
password += random.choice(all)
print("生成的随机密码是:",password)