• 路飞学城Python-Day9(practise)


    def save():
        with open('practise_4', 'w+', encoding='utf-8') as f:
            for i in user_list:
                info = str(i) + '
    '
                info = info.replace('[', '')
                info = info.replace(']', '')
                info = info.replace("'", '')
                info = info.replace(", ", ',')
                f.write(info)
    
    
    def print_info():
        for i in user_list:
            if username in i:print('------用户个人信息------
    姓名	%s
    职业	%s
    部门	%s' % (i[0],i[2],i[3]))
    
    
    
    def change_info():
        print_info()
        change_choice = input('请选择要修改的内容
    1.-----姓名-----
    2.-----职业-----
    3.-----部门-----
    >>>')
        if change_choice == '1':
            new_name = input('请输入新用户名>>>').strip()
            for i in user_list:
                if username in i:i[i.index(username)] = new_name
                save()
            return True
        elif change_choice == '2':
            new_job = input('请输入新职业>>>').strip()
            for i in user_list:
                if username in i: i[2] = new_job
                save()
            return True
        elif change_choice =='3':
            new_dep = input('请输入部门>>>').strip()
            for i in user_list:
                if username in i: i[3] = new_dep
                save()
        else:
            print('错误的命名,正在退出')
    
    
    def change_pwd():
        old_pwd = input('请输入原密码>>>').strip()
        if old_pwd == password:
            new_pwd = input('请输入新密码>>>').strip()
            for i in user_list:
                if username in i: i[1] = new_pwd
                save()
        else:
            print('密码错误!')
    if __name__ == '__main__':
        while True:
            user_list = []
            user_info = {}
            login_status = None
            with open('practise_4', 'r+', encoding='utf-8') as f:
                for line in f.readlines(): user_list.append(line.strip().split(','))
                for i in user_list: user_info[i[0]] = i[1]
            count = 0
            print('------欢迎进入用户登录界面---------')
            while count < 3:
                username = input('请输入用户名>>>').strip()
                password = input('请输入密码>>>').strip()
                if username in user_info and password == user_info[username]:
                    print('欢迎登陆')
                    login_status = True
                    break
                else:
                    print('用户名或密码错误,请重试')
                count += 1
            while login_status == True:
                print('------请选择用户功能------
    1.修改个人信息
    2.打印个人信息
    3.修改密码')
                choice = input('>>>')
                if choice == '1':
                    satus = change_info()
                    if satus == True:
                        break
                elif choice =='2':
                    print_info()
                elif choice =='3':
                    change_pwd()
                else:
                    print("错误的命令,请重试")
    随便写的
    panda,12,新工人,Transportation
    pandaboy,456,walker,IT
    zombie,789,saller,Offer
    文件信息
    Win a contest, win a challenge
  • 相关阅读:
    浅谈三层模式
    javascript的全局变量
    BZOJ 3668 NOI2014 起床困难综合症 贪心
    调试经验--图像
    Mac OS X 10.10 执行 Eclipse 提示须要安装 Java
    ubuntuOS
    BLOB存储图片文件二进制数据是非对错
    API经济产业
    python模块目录文件后续
    MongoDB命令
  • 原文地址:https://www.cnblogs.com/pandaboy1123/p/9276873.html
Copyright © 2020-2023  润新知