day17_job

学生管理系统登录界面

import json

def register():
    id = input('请输入账号:')
    password = input('请输入密码:')
    for x in massage:
        try:
            if x[id]:
                if x[id] == password:
                    print('登录成功!')
                else:
                    print('密码错误!')

        except:
            print('登录失败!账号不存在!')
            break

def login():
    dict1 = {}
    id = input('请输入账号:')
    password = input('请输入密码:')
    dict1[id] = password
    massage.append(dict1)


with open('./test1.json','r',encoding='utf-8')as f:
    massage = json.load(f, encoding='utf-8')

while True:
    print("""
    ======================================
        ❀❀欢迎来到千峰学生管理系统❀❀


                 ◇1. 登   录
                 ◇2. 注   册
                 ◇3. 退   出

    ======================================
    """)
    n = int(input('请选择(1-3):'))
    if n == 1:
        register()
        # input()
    elif n == 2:
        login()
        with open('./test1.json', 'w', encoding='utf-8')as f:
            json.dump(massage,f)
    else:
        break

你可能感兴趣的:(day17_job)