day12-作业

mian.py

from view import loading
from view import star
from function import is_dic_key
from function import register
from function import  is_pwd
import time
def main():
    while True:
        loading()
        n = int(input('请选择:'))
        if n == 1:
           while True:
               name = input('请输入账号:')
               if not is_dic_key(name):
                   print('请先注册')
                   break
               while True:
                   pwd = input('请输入密码:')
                   if is_pwd(name,pwd):
                       print('正在加载系统>>>>>>')
                       time.sleep(3)
                       star(name=name)
                       break
                   else:
                       print('密码错误,请重新输入')
           continue
        if n==2:
            register()
        else:
            print('谢谢使用')
if __name__ == '__main__':
    main()

view.py

import time
def loading():
    time.sleep(1)
    print('='*20)
    print('      欢迎使用系统         ')
    print('         1.登录           ')
    print('         2.注册           ')
    print('         3.退出           ')
    print('='*20)
def star(name):
    print("="*20)
    print('❀❀欢迎%s'%name)
    print('     1.添加学生')
    print('     2.查看学生')
    print('     3.修改学生信息')
    print('     4.删除学生')
    print('     5.返回')
    print('='*20)
def change_view():
    print('='*20)
    print('    1.修改学生姓名')
    print('    2.修改学生学号')
    print('    3.修改学生手机号')
    print('    4.修改学生年龄')
    print('    5.继续')
    print('    6.返回')
    print('='*20)

function.py

import json
def is_dic_key(name):
    list2=[]
    with open('data/manage.json','r',encoding='utf-8') as f:
        content=f.read()
        list1=json.loads(content)
    for item in list1:
        list2.append(list(item)[0])
    if name in list2:
        return True
    else:
        return False
def register():
    dic_mange = {}
    with open('data/manage.json','r',encoding='utf-8') as f:
             content=f.read()
             lis_manage=json.loads(content)
    while True:
       name=input('请输入账号(3~6位):')
       if is_dic_key(name):
           print('输入的账号已存在:')
           continue
       if not 2

你可能感兴趣的:(day12-作业)