python初步编写用户登录
python编写用户登录
    用python写一个脚本,使得这个脚本在执行后,可以产生如下的效果:
    1、用户的账号为:root    密码为:westos
    2、用户账号和密码均输入正确时,输出" login ok !"
    3、用户账号输入正确,密码输入错误,会提示密码错误。
    4、用户账号输入错误,会提示该用户不存在。
    5、用户账号和密码输入错误三次后自动退出并提示输入错误超过三次。
    该用户登录的脚本如下所示:
#!/usr/bin/env python
#coding:utf-8
"""
file: userlogin.py
date: 2017-08-24
author:lijian
desc:
"""
User_Name = "root"
Password = "westos"
print "Please input your username and password !"
for i in 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
 - 21
 - 22
 - 23
 - 24
 - 25
 - 26
 - 27
 - 28
 - 29
 - 30
 - 31
 - 32
 
    执行该脚本后的输出图如下所示:

                
            
        
浙公网安备 33010602011771号