python的第一个程序

#1、验证输入账号密码的正确性
username = "cwb"
password = "123456"
_user = input("请输入账号:")
_passwd = input("请输入密码:")
if _user == username and _passwd == password:
print("login in sucess!!,welcome!!")
else:
print("failed!!")
#2、尝试3次输入账号密码,输入3次后程序退出
username = "cwb"
password = "123456"
for i in range(3):
_user = input("请输入账号:")
_passwd = input("请输入密码:")
if _user == username and _passwd == password:
print("login in sucess!!,welcome!!")
break
else:
print("failed!!")
#3、输入3次后提示 输入已达到上限,程序退出
username = "cwb"
password = "123456"
count = 0
for i in range(4):
if count == 3:
print("尝试此数已达上限,程序退出!!!!")
break
user = input("请输入账号:")
passwd = input("请输入密码:")
if user == username and passwd == password:
print("login in sucess!!,welcome!!")
break
else:
print("failed!!")
count += 1

#4、输入3次后提示 输入已达到上限,输入Y继续,输入N退出
username = "cwb"
password = "123456"
count = 0
for i in range(10):
if count == 3:
msg = input("继续输入Y,退出输入N:")
if msg == "Y":
count = 0
else:
print("尝试此数已达上限,程序退出!!!!")
break
user = input("请输入账号:")
passwd = input("请输入密码:")
if user == username and passwd == password:
print("login in sucess!!,welcome!!")
break
else:
print("failed!!")
count += 1
上一篇:raspberry pi 4b (ubuntu 20.04) 安装 kafka, kafka-manager


下一篇:新装的linux 查询全部用户和修改用户密码