码迷,mamicode.com
首页 > 编程语言 > 详细

python-login

时间:2017-07-07 23:31:16      阅读:262      评论:0      收藏:0      [点我收藏+]

标签:env   strong   lease   user   author   des   错误   please   esc   

Login_1.py

#!/usr/bin/env python
#coding:utf-8
‘‘‘
author:yangying
filename:xi2.py
date:17-7-6 下午5:25
desc:

‘‘‘
user="root"
passwd="westos"
count=0
while count <4:
    if count==3:
        print ("再见")
        break
    else:
        user_input=raw_input("请输入用户名:")
        passwd_input=raw_input("请输入密码:")
        count += 1
        if user==user_input and passwd ==passwd_input:
            print ("登陆成功!")
            break
        else:
            print ("认证失败,请重新输入  你还有%d机会")%(3-count)

Login_2.py

#!/usr/bin/env python
#coding:utf-8
‘‘‘
author:yangying
filename:login_2.py
date:17-7-7 下午9:55
desc:

‘‘‘
users=["mengke",‘songzhao‘]
passwd=[‘hello‘,‘hello‘]
def main():
    str=‘welcome to user login system‘
    a="""
%s
(C)reate
(L)ogin
Enter choice:"""%str.center(10,‘*‘)
    while True:
        choice=raw_input(a).lower()
        if choice == ‘c‘:
            uname=raw_input("please input name:")
            if uname in users:
                print ‘用户已经存在,请直接登陆‘
            else:
                upasswd=raw_input("please input password:")
                users.append(uname)
                passwd.append(upasswd)
                print ‘用户创建成功‘
        elif choice == ‘l‘:
            count=0
            while(count<3):
                uname = raw_input("please input name:")
                upasswd = raw_input("please input password:")
                b=len(users)
                for i in range (0,b):
                    if uname == users[i] and upasswd == passwd[i]:
                        print ‘用户登陆成功‘
                        exit(0)
                    else:
                        count =count+1
                        print ‘用户名或密码错误,请重新输入,你还有%d次机会‘%(3-count)
                        break
                    print ‘你已登陆了3次,请半小时后再登陆‘
                else:
                    print ‘请输入c或l‘
main()

 

 

 

python-login

标签:env   strong   lease   user   author   des   错误   please   esc   

原文地址:http://www.cnblogs.com/yangying2017/p/7134428.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!