【发布时间】:2020-10-27 02:07:09
【问题描述】:
如何使此代码将新用户名和密码存储在用户名为 (K) 和密码为 (V) 的字典中?或者我是否需要将它们存储在列表中,如果需要,我该怎么做?我已经编写了另一段代码用于返回用户的登录,它访问字典中的 (K) 和 (V) 的用户名和密码。
while True:
new_user = input("Consider using alphanumeric and special characters \nCreate new user ID: ")
if len(new_user) < 4:
print("User ID must be more than 4 alphanumeric characters".upper())
continue
elif len(new_user) > 10:
print("User ID must be less than 10 alphanumeric characters".upper())
continue
else:
print("Please confirm user ID ")
break
【问题讨论】:
-
di[user_id]=password就这么简单 -
这取决于您要如何获取它们。直接存储密码不是最佳做法。
-
@RishabhDeepSingh 我写了另一段代码来引用字典。感谢您的回复。存储密码的最佳做法是什么?
标签: python dictionary