码迷,mamicode.com
首页 > 编程语言 > 详细

python初始---程序一(login登陆)

时间:2015-06-29 22:25:00      阅读:229      评论:0      收藏:0      [点我收藏+]

标签:python 登陆 login

#!/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登陆)

标签:python 登陆 login

原文地址:http://4708705.blog.51cto.com/4698705/1669144

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