dic(zip(['example@example.co.uk','thing@thing.co.uk','email@email.co.uk'],
['Games','English','Piano']
如果输入第一封电子邮件和第一封密码,而不是第一封电子邮件和第二封密码或第三封密码,并且只有两者都输入正确,我才能告诉计算机只能访问该帐户。 (与第二个电子邮件和密码相同,第三个等)?
答案 0 :(得分:0)
如果你想将密码存储为字符串(它不是很安全),你可以试试这个(Python 3):
passwords = dict(zip(['example@example.co.uk','thing@thing.co.uk','email@email.co.uk'], ['Games','English','Piano']))
#Get password from user (an example for console, please use a safer way)
email = input("Enter your e-mail adress: ")
password = input("Enter your password: ")
try:
if passwords[email] == password:
#log in
else:
print("This password is wrong")
except KeyError:
print("This account does not exist")