作业

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()
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值