码迷,mamicode.com
首页 > 其他好文 > 详细

编写一个登陆接口

时间:2017-08-15 22:57:30      阅读:175      评论:0      收藏:0      [点我收藏+]

标签:style   pen   登陆接口   ==   exit   用户   pre   put   显示   

要求:
1、输入用户名密码
2、认证成功后显示欢迎信息
3、输错三次后锁定
# -*- coding:utf-8 -*-
import re
count=1
success=0
username = raw_input("Please input username:")
for content in open(‘C:\Users\Administrator.SKY-20140501YNV\Desktop\dataset.txt‘):
username_code = re.split(‘:‘, content)
content_username = username_code[0]
if username==content_username:
break
else:
print "Your user dosen‘t exit"
count=4 for line in open(‘C:\Users\Administrator.SKY-20140501YNV\Desktop\lockfile.txt‘):
line=line.rstrip(\n‘)
if username==line:
count=4
print "Your user has been locked!"
break
while count<4:
code=raw_input("Please input code:")
for content in open(‘C:\Users\Administrator.SKY-20140501YNV\Desktop\dataset.txt‘):
username_code=re.split(‘:‘,content)
content_username=username_code[0]
content_code=username_code[1]
content_code=content_code.rstrip(\n‘)
if content_username==username:
if content_code==code:
print "Welcome to new world!"
success=1
break
else:
print "Mismatch between code and username!"
count+=1
if success==1:
break
if count==4:
print "Yours user has been locked!"
lockfile=open(‘C:\Users\Administrator.SKY-20140501YNV\Desktop\lockfile.txt‘,‘a‘)
lockfile.write(\n‘)
lockfile.write(username)
lockfile.close()

编写一个登陆接口

标签:style   pen   登陆接口   ==   exit   用户   pre   put   显示   

原文地址:http://www.cnblogs.com/date20170814/p/7367969.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!