So I'm making a basic makeshift login validate thing with just a basic text file to "pretend" and what should return True is not. The username check works but not the password check
@staticmethod
def validate_login(filename,username,password):
file = open(filename,'r')
file.readline()
for line in file:
i = [i for i, char in enumerate(line) if char == '|']
print username == line[i[0] + 2:i[1]-1]
print password == line[i[1] + 2:]
print password
print line[i[1] + 2:]
if username == line[i[0] + 2:i[1]-1] and password == line[i[1] + 2:]:
file.close()
print "Login Successful."
return True
file.close()
print "Failed to login. Invalid username or password."
return False
This is the output result. The password matches exactly with the text file yet returns false. The username returns true.What exactly is the issue?? It is driving me insane.
True <--- username matched correctly returns true
False <---passwords apparently don't match, returns false.
DopeFiend97 <--password
DopeFiend97
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…