Python week1-exercise 1 Login interface

Source: Internet
Author: User

File Download: Practise1.tar

Practice One:

    1. Enter User name password
    2. Real welcome information After successful certification
    3. Three-time error after locking
#!/usr/bin/env python#Author:austinname= Input ("please Input User Name:") Deny_file= Open ("Deny.txt","R") line= Deny_file.readline () [:-1] whileline :ifline = =name:Print("Sorry, The user has locked!") Exit () line= Deny_file.readline () [:-1]deny_file.close () Password= Input ("Password:") F= Open ("Passwd.txt","R") line=F.readline () whileline : _user_name= Line.split (":") [0] _user_password= Line.split (":") [1][:-1]    if_user_name = =name:if_user_password = =password:Print("Welcome my friend", Name) break        Else: Count= 1 whileCount < 3: Password= Input ("Password wrong,input angain.")                if_user_password = =password:Print("Welcome my friend", Name) break                Else: Count+ = 1ifCount = = 3:                Print("You have tried three times, user {name} would be locked". Format (name =Name)) Deny_file= Open ("Deny.txt","a") Deny_file.write (name+"\ n") Deny_file.close () line=f.readline () f.close ( )

Postscript:

1. The first week of learning content did not open the file operation, the search for their own operation.

2. After writing, I think the flowchart is really important, can shorten the Time. For Shanbao programmers themselves, drawing flowcharts feel good trouble.

3. It is easier to write with a child function Call. But at that time the writing is almost, do not want to change.

4. The Shanbao programmer guarantees that the next time the program writes a little more comments.

Python week1-exercise 1 Login interface

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.