通过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("您的三次机会已经用完,无法继续输入")
相关推荐
YENCSDN 2020-11-17
lsjweiyi 2020-11-17
houmenghu 2020-11-17
Erick 2020-11-17
HeyShHeyou 2020-11-17
以梦为马不负韶华 2020-10-20
lhtzbj 2020-11-17
夜斗不是神 2020-11-17
pythonjw 2020-11-17
dingwun 2020-11-16
lhxxhl 2020-11-16
坚持是一种品质 2020-11-16
染血白衣 2020-11-16
huavhuahua 2020-11-20
meylovezn 2020-11-20
逍遥友 2020-11-20
weiiron 2020-11-16