|
发表于 2019-12-29 17:21:32
|
显示全部楼层
- dict1 = {}
- users = {}
- def new_user():
- user = input('请输入用户名:')
- while user in dict1:
- user = input('此用户名已经被使用,请重新输入:')
- password = input('请输入密码:')
- dict1[user] = password
- users[user] = False
- print('用户注册成功!')
- def old_user():
- user = input('请输入用户名:')
- if user in dict1:
- if users[user]:
- print("用户锁定,请联系系统管理员!")
- return
- for i in range(3):
- password = input('请输入密码:')
- if password == dict1[user]:
- print('欢迎登录OA系统!')
- break
- else:
- print('密码有误,请核对,连续输错 3 次密码将被锁定!')
- print('用户锁定,请联系系统管理员!')
- users[user] = True
- else:
- print('用户名不存在!')
- def display_list():
- while True:
- choice = input('''|---新建用户:N/n---|
- |---登录账号:E/e---|
- |---退出程序:Q/q---|
- 请输入指令代码:''')
- if choice in 'NnEeQq':
- if choice == 'N' or choice == 'n':
- new_user()
- if choice == 'E' or choice == 'e':
- old_user()
- if choice == 'Q' or choice == 'q':
- confirm = input('您确认要关闭程序吗?(Y/N)')
- if confirm == 'Y':
- break
- else:
- continue
- while choice not in 'NnEeQq':
- print('您输入的指令代码错误,请重新输入!')
- break
- display_list()
复制代码 |
|