Python combat-write basic landing portals

Source: Internet
Author: User

1. Requirements

* Default user name and password, enter user name and password.

* Authentication failed, return failure information, successful authentication, return success information.

* If the user entered three password error, then lock the machine

2, involving knowledge points

* File operations, create a file, write files, read files, append files

* Loop, set the number of user allowed errors, use while loop

* Judge, determine whether the user is locked user if...else ...

3. Analysis

* Use file operations to create a file as a database file. Role 1 Determines whether the user ID in this file, role 2 will fail the user to write the library of the file.

* Set the loop, jump out of the loop correctly, and continue the loop incorrectly.

4. Flowchart

5. Code
1Default_accound ="Xiefangyuan" #set default account and password2Default_password ="19910329"    #set default account and password3user ="192.9.169.49"   #set the user ID to lock the user and subsequently add functions such as acquiring Machine Mac4sql = open ("Sql.log","a")#a database file is recommended for storing user identities5Sql.write ("database files, mistakenly deleted! \ n")#Write6Sql_r = open ("Sql.log","R")#Read database file contents7 ifUserinchSql_r.read ():#determine if the user is locked out8     Print("the user is locked out of the user and cannot be used! ")9 Else:Tenn = 3#set the number of cycles One      whilen >0: An = n-1 -account = str (input ("User name:"))#user Input account password -Password = str (input ("Password:"))#user Input account password the         ifaccount = = Default_accound andPassword = =Default_password: -             Print("enter right, entering! ") -              Break -         Else: +             Print("input Error, please re-enter! You have a chance to do it again.". Format (n)) -     Else: +sql = open ("Sql.log","a") ASql.write (user)#Write User ID at         Print("the number of errors has reached three times, the user is locked! ")

Python combat-write basic landing portals

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.