#!/usr/bin/env python #coding:utf-8 fo=open("user.txt") ''' num=1 while True: line=fo.readline() # print repr(line) print "%s-->%s" %(num,line.rstrip("\n")) num+=1 if len(line)==0: break ''' #从文件中读取所有字符,并存为字典 dict1={} content=fo.readlines() #讲文件结果保存为列表 fo.close() #print content for user in content: name=user.rstrip("\n").split(":")[0] # print name dict1[name]=user.rstrip("\n").split(":")[1] #print dict1 #判断用户的账号密码。都ok提示登陆成功。否则失败 count=0 while True: count+=1 if count >3: print "对不起,您输入的错误次数过多,账户已锁定。请联系管理员" break name=raw_input('请输入用户姓名:').strip() if name not in dict1: print "用户名不存在,请重新输入!!" continue; password=raw_input('请输入您的密码:').strip() if password !=dict1[name]: print "密码输入有误" continue; else: print "恭喜你,登陆成功" break;
python 实战 登录注册
原创
©著作权归作者所有:来自51CTO博客作者shouhou2581314的原创作品,谢绝转载,否则将追究法律责任
下一篇:python 函数应用
提问和评论都可以,用心的回复会被更多人看到
评论
发布评论
相关文章
-
Bootstrap实战 - 注册和登录
注册和登录在社交和商业网站中是必不可少的一个部分。
标签页 表单 Bootstrap 响应式 Glyphicons -
实战CSS:模拟登录注册静态实现
模拟登录注册静态实现
ico html f5 javascript 短信验证码 -
Android项目实战登录&注册
由于项目中大部分界面都有一个后退键和一个标题栏,为避...
android 用户名 xml ide 控件