username = raw_input()
password = raw_input()
user_acct = {'ADMIN':'PASSWORD','READONLY':'PASSWORD','READWRITE':'PASSWORD}
if username and password != user_acct:
print('Invalid Login... Please Try Again')
else:
print('Correct Login')
答案 0 :(得分:0)
Python将懒惰地评估你的if子句,它包含两个条件!
if username
如果不为空则为True
。
然后无需检查密码。结果,打印出Invalid Login... Please Try Again
。
你可能想要
检查密码是否适合此密钥
if username in user_acct and password == user_acct[username]:
print('Correct Login')
else:
print('Invalid Login... Please Try Again')