nr_letters = int(input("How many letters would you like in your password?\n"))
nr_symbols = int(input(f"How many symbols would you like?\n"))
nr_numbers = int(input(f"How many numbers would you like?\n"))</font>[/code]上面代码块中的字符组成了列表中显示的密码生成器的组合。
接下来确保用户可以输入数字,这个整数代表在最终输出显示并使用变量声明时字符出现的次数。
\n:表示输入值会进入到下面一行。
现在,不妨更新其余代码。复制并粘贴以下内容:
nr_letters = int(input("How many letters would you like in your password?\n"))
nr_symbols = int(input(f"How many symbols would you like?\n"))
nr_numbers = int(input(f"How many numbers would you like?\n"))
password_list = []
for char in range(1, nr_letters + 1):
password_list.append(random.choice(letters))
for char in range(1, nr_symbols + 1):
password_list.append(random.choice(numbers))
for char in range(1, nr_numbers + 1):
password_list.append(random.choice(symbols))
random.shuffle(password_list)
password = ""
for char in password_list:
password += char
print("char", char)
# convert list to string
pwd = ''.join(password_list)
print(f"Your random password to use is: {pwd}")</font>[/code]结语
在本文中你开发了一个应用程序,该应用程序每次生成不同的随机密码,从而支持动态使用环境,生成尽可能多的密码。
[attach]144066[/attach]
, '%', '&', '(', ')', '*', '+']
print("Welcome to the PyPassword Generator!")
nr_letters = int(input("How many letters would you like in your password?\n"))
nr_symbols = int(input(f"How many symbols would you like?\n"))
nr_numbers = int(input(f"How many numbers would you like?\n"))
password_list = []
for char in range(1, nr_letters + 1):
password_list.append(random.choice(letters))
for char in range(1, nr_symbols + 1):
password_list.append(random.choice(numbers))
for char in range(1, nr_numbers + 1):
password_list.append(random.choice(symbols))
random.shuffle(password_list)
password = ""
for char in password_list:
password += char
print("char", char)
# convert list to string
pwd = ''.join(password_list)
print(f"Your random password to use is: {pwd}")</font>[/code]结语
在本文中你开发了一个应用程序,该应用程序每次生成不同的随机密码,从而支持动态使用环境,生成尽可能多的密码。
[attach]144066[/attach]
, '%', '&', '(', ')', '*', '+']
print("Welcome to the PyPassword Generator!")
nr_letters = int(input("How many letters would you like in your password?\n"))
nr_symbols = int(input(f"How many symbols would you like?\n"))
nr_numbers = int(input(f"How many numbers would you like?\n"))</font>[/code]上面代码块中的字符组成了列表中显示的密码生成器的组合。
接下来确保用户可以输入数字,这个整数代表在最终输出显示并使用变量声明时字符出现的次数。
\n:表示输入值会进入到下面一行。
现在,不妨更新其余代码。复制并粘贴以下内容: