python-用户登录

  编写登录接口,实现以下功能

1、读取本地存有用户名密码的文件

2、让用户输入用户名密码

3、与本地存有用户名密码的文件进行对比

4、允许用户输入三次,用户名密码正确则跳出循环

代码如下:

for i in  range(3):
with open('E:/1.txt') as f:
line1 = f.readline()
line2 = f.readline()
name = line1.rstrip()
pwd = line2.rstrip()
username = input("Please input your username:")
password = input("Please input your password:")
if username==name and password==pwd:
print("This is True")
break
else:
print("This No true")

猜你喜欢

转载自www.cnblogs.com/chenkya/p/9912385.html
今日推荐