# __author__ = Leo li # !/usr/bin/env python # -*- coding:utf-8 -*- a = open("username.txt","r+") x = open("password.txt","r+") y = x.readlines() b = a.readlines() f = open("msg.txt","r+") m = f.readlines() counter = 0 cmd = 0 ax = 0 while cmd < 1: a = open("username.txt","r+") x = open("password.txt","r+") y = x.readlines() b = a.readlines() print("歡迎來到Python論壇登陸界面") print("1.註冊用戶") print("2.登錄用戶") print("3.退出") chose = input("請輸入你的選項:") if chose == '1': while chose: user = input("請輸入您要註冊的用戶名:") if user+"\n" in b: print("該用戶名已存在,請重新輸入") else: pwd = input("請輸入您的密碼:") c = open("password.txt","a+") c.write(pwd+"\n") a = open("username.txt","a+") a.write(user+"\n") p = open("msg.txt","a+") p.write("True\n") p.close() c.close() a.close() x.close() print("註冊成功!請重新運行登錄程序!") exit() elif chose == '2': while chose: username = input("請輸入您的用戶名:") password = input("請輸入您的密碼:") d = open("username.txt",'r+') if username+"\n" not in d: print("您輸入的用戶名不存在,請重新輸入") d.close() else: q = open("msg.txt",'r+') w = q.readlines() e = b.index(username+"\n") if w[e] == "True\n": if counter <2: if password+"\n" == y[e]: print("登錄成功!歡迎進入") exit() else: print("你的密碼錯誤,請重新輸入") counter+=1 continue else: g = open("msg.txt","w+") m[e] = "False\n" g.writelines(m) g.close() print("由於你嘗試太多次,系統已鎖定此賬戶,請聯繫管理員後重試") print("正在退出程序…………") exit() else: print("您好,由於你的密碼輸入錯誤次數過多,系統已鎖定此賬戶,請聯繫管理員後重試") print("正在返回登錄界面……") print("\n") break elif chose == '3': print("正在退出……") exit() else: print("您的輸入有誤,請輸入您要選擇的序號(“1”,“2”,“3”)")
用戶登錄程序
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.