私は基本認証を使用する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
あなたの質問には、より具体的なタイトルを使用してください。 –