Writing a login interface using Python

Source: Internet
Author: User

Demand:

Writing the Login interface

Enter User name password

Show welcome message after successful authentication

Lock after entering three times


User Information file

Blacklist of files

Blacklist check, do not let login

User name Password determination


Flow chart:

650) this.width=650; "Width=" "height=" 482 "title=" 2017-03-06_143321.png "style=" width:400px;height:482px; "alt=" Wkiol1i9atwi0lvdaacdf-zhuvk118.png-wh_50 "src=" https://s4.51cto.com/wyfs02/M00/8E/4E/ Wkiol1i9atwi0lvdaacdf-zhuvk118.png-wh_500x0-wm_3-wmp_4-s_64924540.png "border=" 0 "vspace=" 0 "hspace=" 0 "/>


Code:

#!/usr/bin/env pythontries = 0lockfile = open (' Account_lock.txt ', ' r+ ', encoding= ' UTF-8 ') Tolockfile = open (' Account_lock.txt ', ' a ', encoding= ' UTF-8 ') userfile = open (' Account.txt ', ' R ', encoding= ' Utf-8 ') Def islock (account):     for line in lockfile:         line = line.strip (' \ n ')          if line == account:             print (' This account is locked ')              exit () Def inaccount (account):    for line in userfile:         col1_user,col2_pass = line.strip (). Split ()          if col1_user == account:             p asstries = 0            while  passtries < 3:                 pass1 = input (' Please enter your password: ')                  if col2_pass == pass1:                    print (' Welcome ')                     exit ()                 else:                     passtries +=1            else:                  tolockfile.write ('%s\n '  % (account))                  print (' account is locked! ')                 exit ()          else:             print (' This account does not exist ')             breakwhile  tries<3:    account = input (' Please enter account: ')     islock ( account)     inaccount (account)     tries +=1else:     print (' This user does not really exist  88 ')     exit () Lockfile.close () Userfile.close () Tolockfile.close () # with open (' Account_lock.txt ', ' a ', encoding= ' UTF-8 ')  as data:   #     data.write ("AAA")    #此方法可以方式忘记文件close #tolockfile = open (' account_lock.txt ', ' a ', encoding= ' UTF-8 ') #open文件后进行追加至最后一行 




This article is from the "Open World" blog, so be sure to keep this source http://voidyao000.blog.51cto.com/12458042/1903626

Writing a login interface using Python

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.