文件操作_用户登陆问题

# username = input("please enter your name:")
# passport = input("please enter your passport:")

# with open("list of info",mode="w", encoding="utf-8" ) as f:
# f.write("{} {}".format(username,passport))

# print("congratulations")
lis = []
i = 0
while i < 3:
uname = input("please enter your username:")
passwd = input("please enter your password:")


with open("list of info", "r", encoding="utf-8") as f:
for line in f:
lis.append(line)
if uname == lis[0].strip() and passwd == lis[1].strip():
print("Login sucessfully")
break
else:
print("wrong")
i += 1

原文地址:https://www.cnblogs.com/jly1/p/9570678.html