print('欢迎登录尚雅梦想python学习系统'.center(30))
print('******' * 8) flag = True
while flag:
order = input('''按'r'或者'R'进行用户注册\n按'l'或者'L'进行用户登录''') if order.upper() == 'R':
flag = True
while flag:
username = input('请输入您要注册的用户名:')
line = open('用户信息', mode='r+', encoding='utf-8')
info = line.read()
info = info.split('\n')
dic_info = {}
for index, item in enumerate(info):
if index % 2 == 0:
dic_info[item] = info[index + 1]
line.close()
if username not in dic_info.keys():
password = input('请输入您的密码:')
line = open('用户信息', mode='r+', encoding='utf-8')
line.read()
line.write('{}\n{}\n'.format(username, password))
line.close()
break
else:
print('您输入的用户名已存在')
continue if order.upper() == 'L':
count = 3
while count > 0:
line = open('用户信息', mode='r+', encoding='utf-8')
info = line.read()
info = info.split('\n')
dic_info = {}
for index, item in enumerate(info):
if index % 2 == 0:
dic_info[item] = info[index + 1]
line.close()
ID = input('请输入您的用户名:')
if ID in dic_info.keys():
psw = input('请输入您的密码:')
if psw == dic_info[ID]:
print('登录成功,请稍后...\n欢迎{}进入python学习系统'.format(ID))
flag = False
break
else:
count -= 1
if count == 0:
print('密码错误三次,正在退出...')
flag = False
break
print('您的密码错误,您还有{}次机会请重新输入:'.format(count)) else:
count -= 1
if count == 0:
print('用户名输入错误三次,正在退出...')
flag = False
break
print('您的用户名输入错误,您还有{}次机会请重新输入:'.format(count))

模拟用户登录升级版,包括用户注册信息保存,以及登录时调取匹配

最新文章

  1. 由Memcached升级到 Couchbase的 Java 客户端的过程记录(一)
  2. web.xml配置error-page
  3. Matlab中的数据类型
  4. Java Hour 14 多线程基础
  5. 【linux】chmod命令详细用法
  6. Codeforces Round #331 (Div. 2) E. Wilbur and Strings dfs乱搞
  7. 从Lumia退役看为什么WP走向没落(从程序员与市场开发的角度,讲的真棒!)
  8. Html5用Canvas制作画图板
  9. Java技术栈思维导图
  10. [转]MYSQL性能查看(命中率,慢查询)
  11. Scientific Toolworks Understand
  12. shell脚本一键安装redis集群[最终版]
  13. MacBookPro-OSX
  14. MapReduce案例:统计共同好友+订单表多表合并+求每个订单中最贵的商品
  15. 2018.11.01 NOIP训练 cost数(搜索+容斥原理)
  16. jQuery ajax的前台代码编写
  17. 卸载vs2017
  18. document.write vs document.getElementById
  19. hdu-5810 Balls and Boxes(概率期望)
  20. 在 IIS8 中保持网站持续运行

热门文章

  1. P3191 [HNOI2007]紧急疏散EVACUATE(费用流)
  2. windows不重装系统和重建MBR分区表来扩展系统盘
  3. DevExpress Winform使用单例运行程序方法和非DevExpress使用Mutex实现程序单实例运行且运行则激活窗体的方法
  4. saltstack的高级管理
  5. 手写call、apply、bind
  6. Linux之scp命令的使用
  7. python常用函数 B
  8. HTML基础 块级元素和内联元素
  9. activemq---点对点/发布订阅模式简单代码示例
  10. Hibernate纯sql查询VO对象封装