Job 1: Writing the Login interface
Requirements: Enter user name password
Show welcome message after successful authentication
Input error three times after locking
Directory structure
- Datalog: Log file
- Lockname: Lock User name file
- Person.db: User name and password file
Main program
#!/usr/bin/env python#_*_coding:utf-8_*_#Author:shenlian" "Job 1: Write Login Interface Requirements: Enter the user name password Authentication successful display welcome information input Error three times after locking" "deflogo (): Num=2 whileTrue:name=input ("Enter Name:") passwd=input (('Enter Password:')) #enter over upper limit lock and log ifnum = =0:Print('Enter the number of times above the limit, exit the program') with open ('Lockname','a') as Lg:lg.write (name+'\ n') Lg.close () Break #detect if the user name is lockedWith open ('Lockname','R') as LG: forIinchlg.readlines (): I=I.split ()ifname==I[0]: Exit ('account is locked') #detect user name password input is correctWith open ('person.db','R') as F: forIinchf.readlines (): I=I.split ()ifNAME==I[0] andPasswd==i[1]: Print('certification success!!! ') returnnameElse: Print('incorrect user name or password re-entry') Num-=1a=logo ()Print(a)
Python First day Job 1