#!/bin/bash/env python
while True:
user_name=raw_input('what is your name?').strip()
if len(user_name) == 0:
print "please input your user_name.if you not,please register!"
continue
else:
file=open('/root/passwd')
state=0 #no login
name_n=0 #no account
user_pass=raw_input('what is your password for user_name?').strip()
for line in file.readlines():
if user_name == line.split()[0]:
name_n=name_n+1
if user_pass == line.split()[1]:
print "login successfully,welcome %s." % user_name
state=state+1
break
else:
for i in xrange(4):
times=3-i
file2=open(r'/root/locked','w')
print "your inputing is error,please re-enter."
user_pass=raw_input('what is your password for user_name?').strip()
if user_pass == line.split()[1]:
print "login successfully,welcome %s." % user_name
state=state+1
break
else:
if times != 0:
print "your inputing is error,please re-enter.And you can enter only %s times" % times
continue
else:
print "you inputed too many times to re-enter.and your account is locked!"
file2.write(str(user_name))
break
print name_n
print state
if name_n == 0:
print "Account does not exist!"
continue
else:
break
python初始---程序一(login登陆)
原创cjt0115 ©著作权
文章标签 Python 登陆 login 文章分类 Python 后端开发
下一篇:grep及正则表达式详解
-
python开发用户注册登陆 python登陆注册程序
python实现循环注册登录_python基础-登录注册逻辑
python开发用户注册登陆 python实现循环注册登录 json User 登录注册 -
Dvbbs的登陆login.asp代码如下:.net 用户名 #include 忘记密码