1.编写简单的登陆接口

#判断用户信息

#用户输入错误后锁定账号

流程图:

代码:

#!/usr/bin/env python

#-*- coding:utf-8 -*-

document1 = open('userinfo.txt', 'r')
document2 = open('falseuser.tex', 'w+')
document3 = open('lock.txt', 'w+')
i = 1
n = 1
while i < 4 and n < 4:
username = input('username:')
password = input('password:')
str1 = document1.read()
h = len(username)
if str1.find(username) >= 0 and document2.read().find(username) == -1:
if str1.find(password, (str1.find(username)+h+1), len(password)):
print('welcome to our web!')
break
else:
document2.write(username)
i += 1
else:
if document2.read().find(username) >= 0:
if str1.find(password, (str1.find(username)+h+1), len(password)) and document3.read().find(username) == -1:
print('welcome to our web!')
elif document3.read().find(username) != -1:
print('you have try 3 times')
break
else:
i += 1
print('confirm password')
else:
print('plese input right username')
n += 1
while i == 3:
document3.write(username)
document3.close()
document2.close()
document1.close()
pycharm python3.7版本可用。
												

最新文章

  1. Linux环境变量设置
  2. js封装的三级联动菜单(使用时只需要一行js代码)
  3. window.location.href无法跳转的解决办法
  4. 【javascript实例】 具有立体效果的图片浏览器
  5. html5 datalist自动完成
  6. Word或者Excel中怎么把 &quot;空格&quot; 替换成 &quot;换行 &quot;
  7. 【Linux】Linux字体颜色
  8. 《JavaScript DOM编程艺术》
  9. C++编写Config类读取配置文件
  10. Objective-C学习篇09—NSNumber与笑笑语法
  11. 所需的防伪表单字段“__RequestVerificationToken”不存在
  12. 201521123003《Java程序设计》第10周学习笔记
  13. [转载] JaCoCo:分析单元测试覆盖率的利器
  14. Android开发学习之路--UI之基本布局
  15. [Android][Recovery] Recovery下找不到sdcard路径
  16. input的三个属性autocomplete、autocapitalize和autocorrect
  17. 52ABP模板 ASP.Net Core 与 Angular的开源实例项目
  18. codeforces546C
  19. 20165237 预备作业3 Linux安装及学习
  20. 进度条(progress_bar)

热门文章

  1. [WEB安全]IIS-PUT漏洞
  2. Spring框架中不同类型的事件
  3. cannot load from mysql.proc. the table is probably corrupted 解决办法
  4. case设计及验证:入口+页面+展示
  5. C++ STL介绍——简介
  6. selinux 开启和关闭
  7. ASP.NET MVC传递Model到视图的多种方式之通用方式的使用
  8. redis json 降低性能 使用 hash
  9. mybatis 的 &lt;![CDATA[ ]]&gt; 标签作用
  10. Spring走向注解驱动编程