![](/img/trans.png)
[英]How to create a python dictionary that will store the username and password for multiple accounts
[英]Python - How to store a username/password from input
我想知道如何從輸入中存儲用戶名和密碼,並將其放入同一個 python 文件上的某種數據庫中。 我希望用戶名和密碼只保存文件打開的時間,並且不需要任何長期存儲數據,在此先感謝!
這是非常簡單的東西,所以我只會給你一個簡短的答案,但你將來可能應該對此做更多的研究,並提供你編寫的代碼。
credentials = {}
def create():
username = input('Username: ')
password = input('Password: ')
credentials[username] = password
def authenticate():
username = input('Username: ')
password = input('Password: ')
return credentials[username] == password
使用 create() 創建用戶並使用 authenticate() 登錄用戶
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.