import time user_list=[] user_login={} error_dic={} petian_list=[] def read_all_user(): if user_list: return with open('account_info.txt', 'rt', encoding='utf-8') as f: text = f.read() if not text: return text = text.split(',') for i in text: temp = i.split('|') print(temp) d_dic = {} d_dic['name'] = temp[0] d_dic['pwd'] = temp[1] def user_exist(username): for user in user_list: if user['name'] == username: return True return False def write_user(name, password): with open('account_info.txt', 'a+', encoding='utf-8')as f: old = ',%s|%s|0' % (name, password) f.write(old) def login(): while True: name=input('请输入用户名 输入0返回上层:') if name=='0': return flag=False for user in user_list: if user['name']==name: flag=True break else: print('用户不存在,请先注册') continue password=input('请输入密码:') for user in user_list: if user['name']==name and user['pwd']==password: print('登陆成功 欢迎:%s'%name) user_login['name']=name user_login['pwd']=password return True print('用户名或者密码不正确,请重新输入') if name not in error_dic: error_dic[name]=1 else: error_dic[name]=1+error_dic[name] def lock_user(username): for user in user_list: if user['name']==username: user['locktime']=str(time.time()) print(username+'被锁定') print(user_list) def read_all_petain(): if petian_list: return with open('bingren.txt','rt',encoding='utf-8') as f: text=f.read() if not text:return text=text.split(',') for i in text: temp=i.split('|') print(temp) d_dic={} d_dic['name']=temp[0] d_dic['bing']=temp[1] d_dic['be_hospital']=temp[2] def write_petain(name,bing,be_hospital): with open('bingren.txt','a+',encoding='utf-8')as f: old=',%s|%s|%s|0'%(name,bing,be_hospital) f.write(old) method_dic={'1':login,'2':write_petain} def main(): read_all_user() while True: print('''欢迎使用xxx医院前台系统 请选择 1:登录 2:病人登入 3:床位查询 0:退出系统 ''') chioce = input('请输入执行的功能:').strip() if chioce == '0': return if chioce not in method_dic: print('输入有误 请重新输入:') continue method_dic[chioce]() main()
作业
最新推荐文章于 2022-10-21 10:20:40 发布