File Download: Practise1.tar
Practice One:
- Enter User name password
- Real welcome information After successful certification
- 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