編寫登錄接口,實現以下功能
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")
