2017python First day Homework

Source: Internet
Author: User

1 #!/user/bin/env python2 #-*-coding:utf-8-*-3 __author__='Howie'4 " "5 Job Requirements:6 1. Enter the user password7 2. Show welcome information after authentication8 3. Three times after the wrong lock9 " "Ten ############################## One " " A Readme: - This is a login interface script that requires the correct user name and password to be entered, and will be locked if the input fails three times.  - now there is a bug that three input errors will only be the first time the user name to lock.  the " " -Account_file ='User.txt' -Lock_file ='Account_lock.txt' -Userpass ='F' +Count =0 -  whileUserpass = ='F'  andCount <3: +Username = input ('Enter user name:') APassword = input ('Enter Password:') atCount +=1 -With open (Lock_file,'R') as F:#Open the Locked users list -          forLineinchF.readlines ():#Traverse each line of the document -Username = Line.strip ()#The string of each row is separated by a space and assigned a value -             ifUsername = = Username:#determine if the user is in the lock table -                 Print('your account is locked') inUserpass ='L' -                  Break to     ifUserpass = ='L':#jump out of white loop when marked L +          Break -With open (Account_file,'R') as F:#Open User List the          forLineinchF.readlines ():#Traverse each line of the document *Username,password = Line.strip (). Split ()#The string of each row is separated by a space and assigned a value $             ifUsername = = Username andPassword = = Password:#determine the user name and password are correctPanax Notoginseng                 Print('Successful Landing') -Userpass ='T' the                  Break #after a successful check mark is T and jump out of the current loop to the while judgment Mark T and then jump out of all loops + ifCount >=3 andUserpass = ='F':#accurate judgment times and markings A     Print("excessive number of errors, the account is locked") theWith open (Lock_file,'A +') as L: +L.write ('\ n') -L.write (Username)
Login Interface Code

This is the first time I've written so many codes in Python.

It's very poorly written.

I think the most important thing is to be clear about the hierarchical relationship of the cycle.

2017python First day Homework

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.