ExistingUser = input("Please enter either Y or N: ")if (ExistingUser) == "N" or "n": newName = input("Please enter your name: ") with open("Userdata.txt", "a") as f: print(newName, file = f) newUserID = input("Please enter your desired username: ") with open("Userdata.txt", "a") as f: print(newUserID, file = f) newPassword = input("Please enter your desired password: ") with open("Userdata.txt", "a") as f: print(newPassword, file = f) f.close()elif (ExistingUser) == "Y" or "y": existingUserID = input("Please enter your username: ") with open("Userdata.txt") as f: if (ExistingUserID) in f.read(): print("True")当我输入 Y 或 y 时,它应该会触发登录过程。相反,它会触发注册。
2 回答
LEATH
TA贡献1936条经验 获得超6个赞
在我看来,您的 If 语句不正确 如果您将它们更改为这种格式,它似乎可以工作
if (ExistingUser == "N" 或 ExistingUser == "n"):
elif (ExistingUser == "Y" 或 ExistingUser == "y"):
采用这种格式: if (ExistingUser) == "N" or "n":
'or "n"' 总是计算为真
添加回答
举报
0/150
提交
取消