当前位置:主页 > 软件编程 > Python代码 >

通过Python编写一个简单登录功能过程解析

时间:2021-07-13 08:22:50 | 栏目: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("您的三次机会已经用完,无法继续输入")

您可能感兴趣的文章:

相关文章