python 实战 登录注册
2016-07-27 15:34
405 查看
#!/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--gevent协程及协程概念
- python 切片
- Python 接口测试
- python中的闭包
- 安装virtualenv No module named virtualenv
- python virtualenv环境运行django
- python3 匹配任意字符
- python sqlite3 的事务控制
- Python选择网卡发包及接收数据包
- python sklearn-01:机器学习基础
- python学习笔记2(对象)
- python入门笔记
- Python 第三方模块安装出现的问题和解决方案.
- python--multiprocessing多进程总结
- 203. Remove Linked List Elements
- Boost python 编程记录
- python的正则表达式
- Python GIL
- 【Python学习】Thread笔记(1)
- Python 实现的简单server-client demo