Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/334.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/python-3.x/15.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
python唯一用户名和密码_Python_Python 3.x - Fatal编程技术网

python唯一用户名和密码

python唯一用户名和密码,python,python-3.x,Python,Python 3.x,我想把这个代码变成一个代码,可以存储用户的用户名和密码以及每个用户的详细信息 name = (input('what is your name ')) age = (input('what is your age ')) (print('please wait your username is processing...')) import time time.sleep(5) (print(name[:3]+age)) password1 = (input('what is your pass

我想把这个代码变成一个代码,可以存储用户的用户名和密码以及每个用户的详细信息

name = (input('what is your name '))
age = (input('what is your age '))
(print('please wait your username is processing...'))
import time
time.sleep(5)
(print(name[:3]+age))
password1 = (input('what is your password '))
(print('your details are saved. You can now log in'))
import time
time.sleep(3)
(input('What is your username')
username == name
(input('what is your password')
password = password1
 (print('you are now logged in')

用最简单的术语,您可以将输入存储在Python字典中,将用户名作为密钥,密码作为值,例如:

user = dict()
user.update({name:password1})
通过将其存储在字典中,可以确保用户名始终是唯一的。当您想要匹配用户名输入时,您可以执行以下操作:

if username in user:
  //do some processing

欢迎来到SO。你的问题不清楚。请提供一份报告。