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
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章