我的程序是为了向人们显示他们输入应用程序的密码,但由于某些原因,它不会显示他们在print('''here are your apps, {} which ones information do you want to view'''.format(a[0])
行中输入的所有应用程序名称。如果用户以前输入过他们在youtube、facebook等网站的信息,它应该打印出来('''有你的应用,youtube、facebook
要查看哪些信息“”。格式(a[0]))
然后用户将键入其中一个并显示其密码。
请不要拒绝我在这里仍然是新的,并试图修复之前问:)。你知道吗
vault_apps = []
users_passwords = ""
def existing_apps():
if len(vault_apps) < 1:
print('''you have currently 0 app and passwords stored on your account''')
locker_menu_func()
else:
for a in vault_apps:
print('''here are your apps, {}
which ones information do you want to view'''.format(a[0]))
break
while True:
users_passwords = input('''
''')
if users_passwords == "":
print('''Please enter a valid answer''')
else:
for a in vault_apps:
if users_passwords in a:
print('''{}
password: {}'''.format(users_passwords, a[1]))
def store_apps():
while True:
app_name = input('''What is the name of the website/app your are adding?
''')
if 0 < len(app_name) < 16:
break
elif app_name == "":
print("Please enter an answer")
while True:
app_password = input('''What is the password of your {} account?
'''.format(app_name))
if app_password == "":
print("Please enter an answer")
else: vault_apps.append([app_name, app_password])
break
while True:
add_app = input('''would you like to add another app and password, yes or no
''')
if add_app.lower() == "no":
locker_menu_func()
elif add_app.lower() == "yes":
store_apps()
else:
print("please enter a proper answer")
def locker_menu_func():
print('''You have opened the locker,
Please select what you would like to do,''')
locker_menu_var = input('''Press: \n1) find your existing passwords \n2) save a new password for your apps
3) see a summary of your password locke \n4) exit password locker successfully
---------------------------------------------------------------------------------
''')
print('''----------------------------------------------------------------''')
while True:
if locker_menu_var == "1": existing_apps()
if locker_menu_var == "2": store_apps()
locker_menu_func()
break
locker_menu_func()
break
找到了第一个app
:。。你知道吗
app
名称(此处不存在密码),则不检查该名称:。。你知道吗
。。你知道吗
。。你知道吗
因此:
输出:
问题出在
existing_apps
方法中。您在vault_apps
上迭代,但是一旦打印了第一个值,您就在break
上迭代。你知道吗我添加了一个修改,其中我们使用列表理解获取名称列表,使用
join()
连接它,然后打印值。你知道吗另请注意一个很好的格式化技巧,您可以使用
f"{some_variable}"
而不是"{}".format(variable)
相关问题 更多 >
编程相关推荐