python--User Authentication Login implementation

Source: Internet
Author: User

# _*_ coding:cp936 _*_  //Support Chinese format import sys import getpass#admin configurationusername= ' Cheeron ' password= ' 1234 ' Counter = 0 #认证登录while True:    If counter <3:         name = raw_input (' Please input your name: '). Strip ()        If Len (nam e) = = 0:            print ' empty name,try again! '            Continue        #passwd = raw_input (' Please input your password: ')        #使用密码隐藏, getpass function        passwd = Getpass.getpass (' Please input your password ')        if password = = passwd and Username = = Name:            print ' Welcome to sign in!%s '% NAME
   else:            print ' name or password is not valid,please try Again! '            Counter+=1            Continue        break    else:        print ' exceeded 3 times user login...exit the script '        Sys.exit ()

 

Result: [[email protected] lesson1]#./qr.py Please input your name:empty name,try again! Please input your name:cheeronplease input your passwordwelcome to sign in Cheeron ... [Email protected] lesson1]#./qr.py Please input your name:cheeronplease input your passwordname or password are not Vali D,please Try Again! Please input your name:cheeronplease input your passwordname or password are not valid,please try Again! Please input your name:cheeronplease input your passwordname or password are not valid,please try again!exceeded 3 times u Ser login...exit the script

  

python--User Authentication Login implementation

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.