withopen(r'c:\Users\laptop001\Desktop\login.txt','a')asfile: file.write("用户名,用户登录密码\n") file.write("zyc,123456\n") file.write("ycz,234567\n") file.write("czy,345678\n") deflogin(usernanme,password): f=open("db",'r') forlineinf: l1=line.split("|") ifl1[0]==usernameandl1[1]==password: returnTruereturnFalsedefregedit(username,password): f=open("db",'a') temp="\n"+username+"|"+passwordf.write(temp) f.close() defmain(): a=input("1:登录,2:注册") ifa=="1": username=input("请输入用户名:") password=input("请输入密码:") r=login(username,password) ifr==True: print("登录成功") else: print("登录失败") elifa=="2": print("注册") user=input("请输入用户名:") passwd=input("请输入密码:") regedit(user,passwd)