Small case: Writing a login interface

Source: Internet
Author: User

1. Enter User name Login

2. Display welcome information after successful authentication

3, password error three times after locking

1 #Author BIGD2 ImportOs,sys3 4I=05  whileI<3:6Username = input ("Enter your name:")7 8     #Check if the user exists9Locked_lines = open ("Locked.txt","r+") # #对文件进行读写Ten      forLocked_lineinchLocked_lines: One         ifUsername = = Locked_line.strip ('\ n'): # #取得姓名 A             Print("You are locked,fuck off") - sys.exit (0) -  the  -Lines = open ("User-passwd.txt","R") # #对文件只读 -      forLineinchlines: -[NAME,PASSWD] = Line.strip ('\ n'). Split (' ', 1) # #取得姓名和密码. Strip remove the symbols on both sides, spilt separate +  -         ifUsername = =Name: +             Print("hello,%s"%(name)) A  atj=0 -              whileJ<3: -                 Print(passwd) -PD = input ("Enter your Passwrod:") -                 ifPD = =passwd: -                     Print("Welcome%s"%(name)) in exit (0) -                 Else: to                     Print("Wrong!you has%d times"% (2-j)) +  -J + = 1 the             Else: *Locked_lines.write (username +'\ n') $                 Print("locked")Panax Notoginseng exit (0) -  the         Else: +             Pass A  the     Else: +         Print("You have %d times"% (2-i)) -i + = 1 $ Else: $     Print("user is not exist.bye!")

Small case: Writing a 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.