基本的に、ユーザー入力を受け入れる基本的なログイン プログラムを作成しました。ただし、現在、ユーザー名とパスワードの組み合わせは 1 つしか許可されていません。複数のユーザー名とパスワードを受け入れるようにしようとしていますが、方法がわかりません。私はPythonを初めて使用し、コードがひどい/乱雑であることを知っています。これは、複数のログインの組み合わせを受け入れるようにしようとしてきたものです。
output = open("logfile.txt", 'a')
login = input("please enter the correct username and password\n")
a = ("username password")("username1 password1")
if a in login:
print("successfully logged in")
import time
localtime = time.asctime(time.localtime(time.time()))
output.write("Somebody successfully logged in at ")
output.write(localtime)
output.write("\n")
output.close()
else:
print("access denied.")
import time
output = open("logfile.txt", "a")
localtime = time.asctime(time.localtime(time.time()))
output.write("Somebody unsuccessfully logged at ")
output.write(localtime)
output.write("\n")
output.close()
` if ブロックをもう 1 つ追加すると、else ブロックも実行されます。また、「a」値「ユーザー名パスワード」があるだけでも機能します。問題は、私が信じている複数の値を持とうとするときです。