Python Initial Write User login

Source: Internet
Author: User

python initial write user loginPython Write User Login
    用python写一个脚本,使得这个脚本在执行后,可以产生如下的效果:    1、用户的账号为:root    密码为:westos    2、用户账号和密码均输入正确时,输出" login ok !"    3、用户账号输入正确,密码输入错误,会提示密码错误。    4、用户账号输入错误,会提示该用户不存在。    5、用户账号和密码输入错误三次后自动退出并提示输入错误超过三次。    该用户登录的脚本如下所示:
#!/usr/bin/env python#coding: Utf-8"" "File:userlogin.pydate:2017-08-24author:lijiandesc:" "" "user_name ="Root" Password ="Westos"Print"Please input your username and password!"For IIn range (1,5):If I <4:in_user_name = Raw_input ("Username:") In_password = Raw_input ("Password:") if user_name = = In_user_name: if Password = = In_password: print "login OK" print "\ n" exit (0) Else: print "password is no OK!" print "\ n" else: print "User is not exist!" print "\ n" else: print "Count is bigger than 3!"       
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21st
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    执行该脚本后的输出图如下所示:

Python Initial Write User login

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.