CSS Ribbon

Reproducing the GitHub Ribbon in CSS

路飞学城Python-Day9(practise)

 

def save():
    with open('practise_4', 'w+', encoding='utf-8') as f:
        for i in user_list:
            info = str(i) + '\n'
            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('------用户个人信息------\n姓名\t%s\n职业\t%s\n部门\t%s' % (i[0],i[2],i[3]))



def change_info():
    print_info()
    change_choice = input('请选择要修改的内容\n1.-----姓名-----\n2.-----职业-----\n3.-----部门-----\n>>>')
    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('------请选择用户功能------\n1.修改个人信息\n2.打印个人信息\n3.修改密码')
            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
文件信息

 

posted on 2018-07-07 11:56  pandaboy1123  阅读(148)  评论(0编辑  收藏  举报

导航