注册登录验证程序

import pickle
def register():
close = input("退出请按Q\q:")
if close.upper() == "Q":
return
else:
dic = {}
user_name = input('请输入注册的用户名:')
user_password = input('请输入用户密码:')
dic['user'] = user_name
dic['pas'] = user_password
print(dic)
with open('userinfo', 'ab') as f1:
pickle.dump(dic, f1)
register()
def logout():
close = input('退出请按Q\q:')
if close.upper() == 'Q':
return
else:
user_name = input("请输入用户名:")
user_password = input('请输入密码:')
with open('userinfo', 'rb') as f2:
while True:
try:
dic = pickle.load(f2)
if user_name == dic['user'] and user_password == dic['pas']:
print('登录成功')
break
except EOFError:
print('登录失败')
break
logout()
posted @ 2020-02-03 15:32  冰灬荷  阅读(200)  评论(0编辑  收藏  举报