0
私はPythonで単純なゲームを作ろうとしています(私はかなり新しく、あまり嫌いではありません!私はアイドルエディタでこれを実行すると:TypeError:ファイルを読み込んだときに 'str'オブジェクトが呼び出せない
Do you have an account? Y or N: n
What is your username: password
Traceback (most recent call last):
File "C:\Users\Bright Bridge\Desktop\Personal\Python Projects\main.py", line 33, in <module>
check_user_name()
File "C:\Users\Bright Bridge\Desktop\Personal\Python Projects\main.py", line 17, in check_user_name
if set_user_name() in read_file().format():
TypeError: 'str' object is not callable
これは私のコードです:
def create_file():
security = open("user.txt", "r+") #I know it's called security, but it's
security.write(set_user_name()) #not really secure...
security.close()
def check_user_name():
security = open("user.txt", "r")
read_file = security.read()
if set_user_name() in read_file().format():
print("Welcome " + set_user_name())
security.close()
else:
print("Invalid Username")
security.close()
def login(username, password):
pass
def set_user_name():
user_name = input("What is your username: ")
return user_name
account_check = input("Do you have an account? Y or N: ")
if account_check == "y" or "Y" or "yes" or "Yes" or "YES":
check_user_name()
else:
create_file()
私が間違って何をしているのですか?