标签: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