我正在嘗試製作一個工作用戶註冊程序。當詢問用戶名時,系統會查看輸入的文本是否已經存儲。如果用戶名已經存儲,它將要求該用戶的密碼。但是,如果用戶名未被存儲,它將要求輸入密碼。輸入這些內容後,該腳本將附錄到.py文件的.txt文件中以創建新帳戶。帳戶建立後,腳本可以讀取.txt或.py文件以獲取登錄信息。我當前的登錄代碼:Python用戶註冊
loop = "true"
while(loop == "true"):
username = input("Enter Username: ")
password = input("Enter Password: ")
h = input ("Do You Need Help [Y/N]: ")
if(h == "Y" or h == "y" or h == "yes" or h == "Yes"):
print ("Enter username and password to login. If you do not have an account yet, enter 'Guest' as the username and press enter when it asks for the password.")
elif(h == "N" or h == "n" or h == "no" or h == "No"):
print (" >> ")
if(username == "Hello World" and password == "Hello World" or username == "Test User" and password == "Test User" or username == "Guest"):
print ("Logged in Successfully as " + username)
if(username == "Guest"):
print ("Account Status: Online | Guest User")
if not (username == "Guest"):
print ("Account Status: Online | Standard User")
如何製作一個數據庫,python可以讀取用戶名和密碼?另外,你如何做到這一點,使Python可以附加到數據庫添加更多的用戶名和密碼?
這是Python v3.3.0 Mac OSX 10.8
預先感謝您!
您遇到的問題是什麼? – Bazinga
如何製作一個python可以讀取用戶名和密碼的數據庫?另外,你如何做到這一點,使Python可以附加到數據庫添加更多的用戶名和密碼? –
例如'import sqlite3'和[SQLite Python教程](http://zetcode.com/db/sqlitepythontutorial/) – furas