python初始---程式一(login登陸)

來源:互聯網
上載者:User

標籤: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登陸)

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.