Python Learning day1 Jobs

Source: Internet
Author: User

Job Content:

Pass

Flow chart:

Code: 1, Master File
1 ImportSYS2 3Lock ="Lock.txt"4LogFile ="Login.txt"5Login_info =06i =07 8  whileI < 3 andlogin_info==0:9Name = input ("Please input your name:")Ten  Onef = open (lock,"R") A      forLineinchf.readlines (): -         #if name in line: -         ifName = =Line.strip (): the f.close () -Sys.exit ('\033[32:1m User%s has been locked \033[0m'%name) -  -Password = input ("Please input password:") +  -f = open (logfile,"R") +      forLineinchf.readlines (): AUser_file, Pass_file =Line.split () at         ifUser_file = = Name andPass_file = =Password: -             Print("bingo!") -Login_info = 1 -              Break -     Else: -         Print("You name or password is errer!") ini + = 1 - f.close () to Else: +     ifi = = 3 andLogin_info = =0: -f = open (lock,"a") theF.write (name +"\ n") * f.close () $         Print('\033[32:1m User%s has been locked \033[0m'% name)
2. System user account password information
1 Root ROOTGM 2 GM 123453 HLR hlr123
3, the current system is locked user information
gm

Test Result: 1, Test lock user can login system

2. Test login 3 times can login

3. Test login 1 times can login

4, test login 3 failed, whether the account will be locked

Python Learning day1 Jobs

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.