Python file invoke little exercise-user login and lock

Source: Internet
Author: User

1 #-*-coding:utf-8-*-2 " "3  --------------------------------------------4 already has the function: Enter the user name password, the authentication succeeds displays the welcome message, after the mistake three times the permanent lock5 To be added later: timed unlock; Use a large number of storage users, such as databases, and call6  --------------------------------------------7  " "8Username ='AAA'9Password ='AAA'Ten  One defUserLock (): ATry_times =0 -      whileTry_times < 3: -Usernameinput = input ('User name:') the         ifUsernameinput = =Username: -With open ('UserLock','R', encoding='Utf-8') as Userlock_file: -                 ifUsernameinputinchUserlock_file: -                     Print("user%s has been locked, please contact customer service (Customer service Tel: 10086)! "%usernameinput) +                     return0 -                 Else: +Times =0 A                      whileTimes < 3: atPasswordinput = input ('Password:') -                         ifPasswordinput = =Password: -                             Print("%s, thank you for signing in! \n\t Welcome! "%username) -                             return0 -                         Else: -                             Print("Password input Error! Please re-enter! ") inTimes + = 1 -                     Else: toWith open ('UserLock','r+', encoding='Utf-8') as Fileuserlock: + fileuserlock.write (usernameinput) -                         Print("user is locked, please contact customer service (Customer service Tel: 10086)! ") the                         return0 *         Else: $             Print("Invalid user name! ")Panax NotoginsengTry_times + = 1 -  the  +UserLock ()

Python file invoke little exercise-user login and lock

Related Article

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.