ユーザがアカウントを持っていない場合にアカウントを作成できるようにしたいのですが、そうした場合、ログインしてユーザ名とパスワードをチェックすることができます彼らがアカウントを作ったときに このコードはサインアップでは動作しますが、ログインした人が既にアカウントを作成している場合はチェックしません。ログインまたはサインアッププログラムpython
import os.path
if os.path.exists("username"):
login()
else:
make_account()
def make_account
filename = ("username");
with open (filename, "w") as f:
f.write (input("Enter a username: "));
filename = ("password");
with open (filename, "w") as f:
f.write (input("Enter a password: "));
def login
username = input("Enter your username: ")
password = input("Enter your password: ")
check()
def check
if username == open("username").read(): and
passsword == open("password").read():
print("Successful login")
else:
print('Incorrect')
とは?間違いましたか?コードに問題がある場合は、質問を編集してください。 – Zcode
関数を定義するための構文はわかりますか? –
あなたの質問は何ですか? – ranieribt