DAY 7 login登陆入口

# athor : DevilsWhite
# -*- coding:UTF-8 -*-
Account = {"alex":123,"white":456,"angelbaby":789,"xiaoboya":123456789}
username_ = dict.keys(Account)
with open('msg.txt','r') as f1:#使用“open with”语句的‘r’、‘a’模式进行文本读取、新增
msg = f1.readlines()
count = 1

while count <= 3:
username = input("Username:")
if username in msg: #之所以只有‘username’,是因为如果登录名已经锁了,密码也就没必要了
print("Your account is locked.")
break
if username in username_ :
password = int(input("Password:"))
if password == Account[username]: #字典的读取
info = '''
-------- Login System --------
|Welcome , my fiend!
| %s
-------- For the horde!-------
'''%(username)
print(info)
break
else:
print("Your password is wrong,please again..")
if count == 3:
print("Sorry, your account is locked.")
with open('msg.txt', 'a') as f1:
f1.write(username)
count += 1
else:
print("Please note that when you make your name,and when you log in ,it IS case senstive.")
if count == 3:
print("Sorry, your account is locked.")
with open('msg.txt', 'a') as f1:
f1.write(username)
count += 1

猜你喜欢

转载自www.cnblogs.com/DevilsWhite/p/10914996.html