python 用字典创建一个平台的用户信息
2018-04-02 15:07
316 查看
用字典创建一个平台的用户信息(包含用户名和密码)管理系统,新用户可以用与现有系统帐号不冲突的用户名创建帐号,已存在的老用户则可以用用户名和密码登陆重返系统。你完成了吗?建议程序框架为:
def newusers():
enter a name
if the name is used in the system:
enter again
else:
set the password
… …
def oldusers():
Enter the username and password
if password is right:
print(name, 'welcome back ')
else:
print('login incorrect')
… …
def login():
option = '''
(N)ew User Login
(O)ld User Login
(E)xit
"""
Enter the option
'''
if __name__ == '__main__':
login()代码:option = {'AA':'11','BB':'22'}
def newusers():
name=input('enter a new name:')
if name in option:
newusers()
else:
option[name]=input('set the password:')
def oldusers():
name=input('enter a name:')
password=input('enter password:')
if name in option and password in option.get(name):
print(name, 'welcome back ')
else:
print('login incorrect')
def login():
print('新用户注册')
newusers()
print('老用户登陆')
oldusers()
if __name__ == '__main__':
print(option)
login()
print(option)
效果:{'AA': '11', 'BB': '22'}
新用户注册
enter a new name:CC
set the password:33
老用户登陆
enter a name:CC
enter password:33
CC welcome back
{'AA': '11', 'BB': '22', 'CC': '33'}
def newusers():
enter a name
if the name is used in the system:
enter again
else:
set the password
… …
def oldusers():
Enter the username and password
if password is right:
print(name, 'welcome back ')
else:
print('login incorrect')
… …
def login():
option = '''
(N)ew User Login
(O)ld User Login
(E)xit
"""
Enter the option
'''
if __name__ == '__main__':
login()代码:option = {'AA':'11','BB':'22'}
def newusers():
name=input('enter a new name:')
if name in option:
newusers()
else:
option[name]=input('set the password:')
def oldusers():
name=input('enter a name:')
password=input('enter password:')
if name in option and password in option.get(name):
print(name, 'welcome back ')
else:
print('login incorrect')
def login():
print('新用户注册')
newusers()
print('老用户登陆')
oldusers()
if __name__ == '__main__':
print(option)
login()
print(option)
效果:{'AA': '11', 'BB': '22'}
新用户注册
enter a new name:CC
set the password:33
老用户登陆
enter a name:CC
enter password:33
CC welcome back
{'AA': '11', 'BB': '22', 'CC': '33'}
{'AA': '11', 'BB': '22'} 新用户注册 enter a new name:CC set the password:33 老用户登陆 enter a name:aa enter password:12 login incorrect {'AA': '11', 'BB': '22', 'CC': '33'}
{'AA': '11', 'BB': '22'} 新用户注册 enter a new name:CC set the password:33 老用户登陆 enter a name:AA enter password:22 login incorrect {'AA': '11', 'BB': '22', 'CC': '33'}
相关文章推荐
- 用字典创建一个平台的用户信息(包含用户名和密码)管理系统
- 用字典创建一个平台的用户信息(包含用户名和密码)管理系统,新用户可以用与现有系统帐号不冲突的用户名创建帐号,已存在的老用户则可以用用户名和密码登陆重返系统。
- 创建并部署一个Servlet,要求在实现用户登录功能,当用户名和密码正确时跳转到欢迎页面,否则提示出错信息
- python--字典--实战分析--用户信息查询接口设计
- 将一段用户信息用python字典打印出来
- python获取的信息列表微信公共平台和用户头像
- 通过字典-python实现用户信息查询
- 架构一个数据交换与信息共享平台
- python创建和使用字典实例详解
- Python3 字典使用上的一个小细节
- SharePoint 创建SSP时出现异常,信息如 设置失败: 找不到 Windows NT 用户或组 '【域名】/administrator'。请再次检查该名称。
- 设计思路.Thinking.基于Python构建一个可扩展的运维自动化平台?
- 如何有效合并两个文件:一个是1亿条的用户基本信息,另一个是用户每天看电影连续剧等的记录,5000万条。其中内存只有1G。
- Python 字典一个易犯的错误
- 创建一个只有select 权限的用户
- Python创建二维数组实例(关于list的一个小坑)
- PYTHON如何判断一个字典或者列表为空
- 用Python3、NetCore、Shell分别开发一个Ubuntu版的定时提醒(附NetCore跨平台两种发布方式)
- Linux 创建、删除和改变用户信息 —— adduser useradd usermod deluser
- 安装程序无法创建一个DCOM用户帐号来注册 VC 安装 错误