Python Initial---program one (login login)

Source: Internet
Author: User

#!/bin/bash/env python
While True:
User_name=raw_input (' What's your name? '). Strip ()
If Len (user_name) = = 0:
Print "Please input your user_name.if not,please register!"
Continue
Else
File=open ('/root/passwd ')
State=0 #no Login
Name_n=0 #no Account
User_pass=raw_input (' What's your password for user_name? '). Strip ()
For line in File.readlines ():
if user_name = = Line.split () [0]:
Name_n=name_n+1
if User_pass = = Line.split () [1]:
Print "Login successfully,welcome%s."% user_name
State=state+1
Break
Else
For I in Xrange (4):
Times=3-i
File2=open (R '/root/locked ', ' W ')
Print "Your inputing is Error,please re-enter."
User_pass=raw_input (' What's your password for user_name? '). Strip ()
if User_pass = = Line.split () [1]:
Print "Login successfully,welcome%s."% user_name
State=state+1
Break
Else
If times! = 0:
Print "Your inputing is error,please re-enter. And you can enter the only%s times "% times"
Continue
Else
Print "inputed too many times to re-enter.and your account is locked!"
File2.write (str (USER_NAME))
Break
Print Name_n
Print State
If Name_n = = 0:
Print "account does not exist!"
Continue
Else
Break

Python Initial---program one (login login)

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.