![](/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.