기본 인증을 사용하는 python (3.4) 코드를 작성하고 있습니다. 사용자 이름 & 암호를 텍스트 파일 (abc.txt)에 저장했습니다.
로그인 할 때 코드는 텍스트 파일의 첫 번째 줄만 받아들입니다. &은 나머지 자격 증명을 무시하고 잘못된 자격 증명 오류를 제공합니다.Python 3.4는 텍스트 파일에서 한 줄 이상을 읽지 않습니다.
내 코드 :
with open('abc.txt') as f:
credentials = [x.strip().split(':') for x in f.readlines()]
for username, password in credentials:
user_input = input('Please Enter username: ')
if user_input != username:
sys.exit('Incorrect incorrect username, terminating... \n')
user_input = input('Please Enter Password: ')
if user_input != password:
sys.exit('Incorrect Password, terminating... \n')
print ('User is logged in!\n')
abc.txt : 당신은 첫 번째 라인을 확인하고 있기 때문에 무슨 일이 일어나고
Sil:xyz123
smith:abc321
질문에 더 구체적인 제목을 사용하십시오. –