Python First day Job 1

Source: Internet
Author: User

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
    1. Datalog: Log file
    2. Lockname: Lock User name file
    3. 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

Related Article

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.