Python Beginner Exercise 01: Simple Login Verification

Source: Internet
Author: User

login.py

#!/usr/bin/python
Ufile= ' User.txt '
Lockfile= ' Lock.txt '

Import Tab,os

Logincleck = False
Loginlock = False
Locknum=1
While True:
Print "Input ID and Password.please"
Userid=raw_input ("UserID:"). Strip ()
Userpass=raw_input ("Password:"). Strip ()
If Len (userid) > 0 and Len (userpass) > 0:
Break
While True:
F1=file (Ufile)
F2=file (Lockfile)
For F2line in F2.readlines ():
If F2line.split () [0] = = UserID:
Loginlock = True
Break
Else
F2.close
If Loginlock is True:
Print "Error:id is lock"
Break
For F1line in F1.readlines ():
If F1line.split () [0] = = UserID and F1line.split () [1] = = Userpass:
Print "Welcome%s"%userid
Logincleck = True
Break
If Logincleck is True:
Break
If Locknum > 3:
Print "Error:password > 3, ID is lock"
F3=file (Lockfile, ' a ')
F3.write ("%s\n"% userid)
F3.close
Break
Print "Error:id or Password error.input password.please"
Userpass=raw_input ("Password:"). Strip ()
Locknum=locknum+1


This article is from the "cloud Transverse qinling Home" blog, please be sure to keep this source http://loren2012.blog.51cto.com/5089992/1869061

Python Beginner Exercise 01: Simple Login Verification

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.