我正在做一个程序,将提示用户登录使用他们的用户名和密码。我有一个文本文件(userandpassword.txt),其中包含用户名和密码的列表。所以,用户输入他们的用户名和密码,他们的输入将与文本文件中的用户名和密码相匹配。如果匹配,他们可以登录,如果不匹配,它将打印出“无效的用户名或密码”。下面是我的资料。
文本文件(userandpassword.txt)
john abcd
mary efgh
jane ijkl
我的密码
string line = " ";
ifstream readFile("userandpassword.txt");
string
我的代码:
userlog = input("What is your username?")
passlog = input("What is your password?")
for fileread in open("accounts.txt", "r").readlines():
file = fileread.split()
if userlog == file[0] and passlog == file[1]:
print("Succesfully logged in"
这是我的Wicket 1.5应用程序登录页面的onSubmit()方法:
@Override
public void onSubmit() {
super.onSubmit();
User theUser = loginForm.getModelObject();
/* call a DAO function to check the user's credentials */
if(/* DAO call succeeds*/) {
MyCustomeSession authSession = (MyCustomSession)Session.get();