Python编写一个登录功能

需求: 

写一个登录的程序,
1、最多登陆失败3次
2、登录成功,提示欢迎xx登录,今天的日期是xxx,程序结束
3、要检验输入是否为空,账号和密码不能为空
4、账号不区分大小写

import datetime

count = 0
while count<3:

username = input("username: ")
pwd = input("password: ")
date = datetime.date.today()

if username.strip()=="" or pwd.strip()=="":
print("您输入的是空值,请重新输入")
count = count + 1
continue
elif username =="shenxianlu" and pwd == "123456":
print("%s,欢迎您登录,今天日期是:%s" %(username,date))
break
else:
print("输入的账号密码有误请重试")
count = count+1
else:
print("您的三次机会已经用完,无法继续输入")

疑问:用户名和密码如何不区分大小写,还没有搞懂

猜你喜欢

转载自www.cnblogs.com/lapt/p/11456289.html