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