2016-09-20 62 views
-2

所以我目前正在創建一個需要真正基本認證的測驗程序。這是我的僞碼。檢查用戶輸入的.txt文件(Python 2.7.11)

Start 
Open UserCredentials.txt (This is where the user ID is stored) 
Get UserID 
If UserID is in UserCredetials.txt(This is the part that i could not figure out how to do) 
..Passtries = 0 
..While passtries != 1 
....Get password 
....If password is UserCredentials.txt(The other part which i couldnt do.) 
......Passtries = 1 (Correct password, it will exit the loop) 
....else 
......Passtries = 0 (wrong password, it will continue looping) 
....WhileEnd 

所以這裏的問題是,我無法弄清楚如何檢查基礎上,UserCredentials.txt文件什麼用戶輸入並在Python編寫代碼了。 (Python的2.7.11)

注意,在UserCredentials.txt,用戶ID和密碼由側方存儲[Izzaz ABC123]

而且我仍然過一種新蟒蛇,這樣下去容易在我身上:)
任何幫助表示讚賞。

+0

取看看['raw_input()'](https://docs.python.org/2/library/functions.html#raw_input) – JazZ

回答

0

。你應該開始使用數據容器和XML或JSON字典的格式

UserCredentials.xml 

members_dict: 
    User(Name = "izzaz", Passwort: "abc123") 
    User(Name = "isssz", Passwort: "asassa") 

.start 
.open UserCredentials.xml/json 
.get members_users 
.if user_id_input in members_users continue 
.if user_passwort_input == members[user_id_input][passwort]: 

它只是一個指南它如何工作,更多有關OrderedDictXml Parsingcreate simple Xml file