python练习1 登录和三级菜单

'''题目
作业二:编写登录接口
输入用户名密码
认证成功后显示欢迎信息
输错三次后锁定
'''
import getpass

with open('name','r') as f:
list1 = f.readlines()
dict1 = {}

for i in range(0,len(list1)):
# dict1[i] = list1[i].rstrip('\n').split()
list1[i] = list1[i].rstrip('\n').split()

count = 0
while count < 3:
username1 = input("请输入您的用户名:")
# password1 = getpass.getpass("请输入您的密码:")
password1 = input("请输入您的密码:")
count += 1
if [username1,password1] in list1:
print("登录成功")
break
else:
print("登录失败")
continue
else:
print("尝试次数过多,请重新登录")
posted @ 2018-10-30 09:51  TwoB  阅读(69)  评论(0编辑  收藏  举报