Old boy Python automated operations 1

Source: Internet
Author: User

1 #!/usr/bin/env python2 #-*-coding:utf-8-*-3 4 ImportRe5 6 deflogin ():7 8F=open ("User",'R')#reads the user configuration file. 9Cont=f.readlines ()#ReadLines to return a list of the elements of the reading profession as an elementTen f.close () OneAllname=[]#initialize a list of users AAllpasswd=[] -          forIinchRange (0,len (cont)-1):#Len Gets the number of elements in the Cont list -Onecont=cont[i].split ()#loops through a line of content and splits it into a list, split () splits the string with a space separator and returns a list.  theONENAME=ONECONT[0]#Loop through an account in one row -ONEPASSWD=ONECONT[1]# -Allname.append (Onename)#loop to append the account number to the user list for each row - allpasswd.append (ONEPASSWD) +Lf=open ("User.lock",'R') -Lcont=Lf.readlines () + lf.close () A         Print(Lcont) at         Print(Allname) -         Print(ALLPASSWD) -  -Cont=0 -          whileCont < 3: -Username=raw_input ("Login User:"). Strip () inPasswd=raw_input ("Password:") -                 ifUsername not inchAllname: to                         Print("No this accont!") +  -                 elif(Username +"\ n")inchLcont: the                         Print("your account has been locked! Please contact admin!") *                          Break $                 Else:Panax NotoginsengRel_passwd_index=allname.index (username)#The index of the account in the list of users, the index of the list of users and the index of the password list is corresponding, so we also > took the account password in the password list index -Rel_passwd=allpasswd[rel_passwd_index]#take the real password for the account the                         ifpasswd==rel_passwd: +                                 Print("Login success!") A                                  Break the                         Else: +                                 Print("Password is error!") -Cont+=1 $         ifCont >= 3: $                 Print("Excessive password Error,your account had been locked! Please contact admin!") -Nf=open ("User.lock",'WB') -Nf.write (username+"\ n") the nf.close () - Wuyi  theLogin ()

Old boy Python automated operations 1

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.