选课系统 -- # 25 -26

readme

分析:

选课系统 -- # 25 -26
  1 本周作业
  2 
  3 角色:学校、学员、课程、讲师
  4 要求:
  5 1. 创建北京、上海 2 所学校
  6 2. 创建linux , python , go 3个课程 , linux\py 在北京开, go 在上海开
  7 3. 课程包含,周期,价格,通过学校创建课程
  8 4. 通过学校创建班级, 班级关联课程、讲师
  9 5. 创建学员时,选择学校,关联班级
 10 5. 创建讲师角色时要关联学校,
 11 6. 提供两个角色接口
 12 6.1 学员视图, 可以注册, 交学费, 选择班级,
 13 6.2 讲师视图, 讲师可管理自己的班级, 上课时选择班级, 查看班级学员列表 , 修改所管理的学员的成绩
 14 6.3 管理视图,创建讲师, 创建班级,创建课程
 15 
 16 7. 上面的操作产生的数据都通过pickle序列化保存到文件里
 17 
 18 角色:学校、学员、课程、讲师
 19 要求:
 20 
 21 创建北京、上海 2 所学校
 22 
 23 学校
 24 
 25 属性:名字  地址  电话    课程列表 (目前可以将课程存到学校中 后期要反过来 在课程中存储学校信息)
 26 
 27 行为: 创建课程
 28 
 29 创建linux , python , go 3个课程 , linux\py 在北京开, go 在上海开
 30 
 31 课程
 32 
 33 属性:课程名称 价格 周期  学校名称
 34 
 35 行为:
 36 
 37 课程包含,周期,价格,通过学校创建课程
 38 
 39 
 40 
 41 通过学校创建班级, 班级关联课程、讲师
 42 
 43 班级
 44 
 45 属性:班级名称  课程名称    老师名称
 46 
 47 行为:
 48 
 49 
 50 
 51 创建学员时,选择学校,关联班级
 52 
 53 学生
 54 
 55 属性:姓名,性别,年龄  学校名称   班级名称
 56 
 57 行为:选择校区   选择课程   加入班级   交学费    注册
 58 
 59 
 60 
 61 创建讲师角色时要关联学校,
 62 
 63 讲师
 64 
 65 属性:姓名年龄,性别,学校名称
 66 
 67 行为: 修改学生成绩     选择班级  查看班级学员列表
 68 
 69 
 70 
 71 
 72 
 73 提供三个角色接口
 74 
 75   ​    学员: 登录 注册 选课 交学费   查看自己的分数
 76 
 77   ​    老师: 登录, 选择班级 , 修改学员成绩  查看学员信息
 78 
 79   ​    管理: 登录,注册, 创建校区,创建讲师,创建课程,创建班级
 80 
 81   ​
 82 
 83   ​
 84 
 85 管理员:
 86 
 87 属性: 账号 密码
 88 
 89 行为:创建学校,创建班级,创建讲师,  创建课程
 90 
 91 
 92 
 93 上面的操作产生的数据都通过pickle序列化保存到文件里
 94 
 95 pickle 可以直接存储任何类型对象
 96 
 97 需求分析 :
 98 
 99 明确要做的程序 具备哪些功能,并分析 每个功能是否可以用代码实现, 产生需求文档
100 
101 技术选型:
102 
103   1.要使用的技术是否已经成熟  (使用的人多,有完整官文档,还有相对活跃的社区)
104 
105 需要考虑开发团队是否能够hold住该技术
106 
107 
108 
109 面向对象 还是 面向过程
110 
111 如果项目体积较大,后续可能需要修改需求或是增加需求,优先考虑 面向对象
112 
113 
114 
115 1.分析需求 确定需要哪些对象和类 ,分别有哪些特征和行为
116 
117 三层:
118 
119 用户层V  接口层C  数据访问层M
120 
121 用户层 :与用户交互  输出数据  或者接收输入
122 
123 接口层:  1.判断 验证 组装 数据  交给给数据访问层 来存储    2.从数据访问层拿到数据 组装成用户可以看懂的格式 交给用户层
124 
125 数据访问:  提供数据的读取和存储
126 
127 
128 
129 model  模型 就是一个对象 专门用于描述数据  相当于数据容器
130 
131   需要的文件应该放在那一层
132 
133 与用户直接打交道的  例如请输入功能序号  放到用户层
134 
135 user_view
136 
137 teacher_view
138 
139 admin_view
140 
141 一堆类 例如学生 课程   等 放在数据访问层
142 
143 接口层:
144 
145 user_interface
146 
147 teacher_interface
148 
149 admin_interface
150 
151 数据访问层:
152 
153 DBHandler
154 
155 标准文件目录:
156 bin
157 
158 start.py
159 
160 conf
161 
162 settings.py
163 
164 lib
165 
166 common.py
167 
168 core
169 
170 user_view
171 
172 teacher_view
173 
174 admin_view
175 
176 db
177 
178 DBHandler
179 
180 models
181 
182 interface
183 
184 user_interface
185 
186 teacher_interface
187 
188 admin_interface
189 
190 logs
191 
192 一堆日志文件
193 
194 
195 
196 从用户层开始写  功能选择
197 
198 用户的登录 注册
199 
200 先后顺序 不是必须的
201 
202 管理员
203 
204 学生
205 
206 老师
readme

用户功能层

core

admin.py

选课系统 -- # 25 -26
  1 from interface import common_interface,admin_interface
  2 from lib import common
  3 # \n1.注册
  4 def register():
  5     while True:
  6         name = input("admin_name>>>:").strip()
  7         type = 'admin'
  8         flag = common_interface.select_name(type,name)
  9         if flag:
 10             print('账号已存在,请重新输入')
 11         else:
 12             pwd = input("pwd>>>:").strip()
 13             re_pwd = input("re_pwd>>>:").strip()
 14             if pwd and re_pwd:
 15                 if pwd == re_pwd:
 16                     # 调用接口层
 17                     msg = common_interface.register_interface(type,name,pwd)
 18                     if msg:
 19                         print(msg)
 20                         break
 21                 else:
 22                     print("两次密码不一致")
 23             else:
 24                 print("密码和验证密码不可为空")
 25 
 26 # \n2.登录
 27 def login():
 28     while True:
 29         name = input("admin_name>>>:").strip()
 30         type = 'admin'
 31         flag = common_interface.select_name(type,name)
 32         if flag:
 33             print('账号输入正确,请输入密码')
 34             pwd = input("pwd>>>:").strip()
 35             if pwd:
 36                 # 调用接口层
 37                 flag,msg = common_interface.login_interface(type, name, pwd)
 38                 if flag:
 39                     print(msg)
 40                     from core import src
 41                     src.user_info['name'] = name
 42                     src.user_info['type'] = type
 43                     break
 44                 else:
 45                     print(msg)
 46             else:
 47                 print("密码不可为空")
 48         else:
 49             print('账户输入错误')
 50 # \n3.创建校区
 51 @common.login_auth
 52 def create_school():
 53     while True:
 54         name = input("name>>>:").strip()
 55         type = 'school'
 56         flag = common_interface.select_name(type,name)
 57         if flag:
 58             print('账号已存在,请重新输入')
 59         else:
 60             addr = input("addr>>>:").strip()
 61             if addr:
 62                 # 调用接口层
 63                 from core import src
 64                 admin_name = src.user_info['name']
 65                 msg = admin_interface.create_school_interface(admin_name,name,addr)
 66                 if msg:
 67                     print(msg)
 68                     break
 69             else:
 70                 print('地址不可为空')
 71 
 72 # \n4.创建讲师
 73 @common.login_auth
 74 def create_teacher():
 75     from core import src
 76     admin_name = src.user_info['name']
 77     while True:
 78         teacher_name = input("teacher_name>>>:").strip()
 79         if teacher_name == 'q': return
 80         type = 'teacher'
 81         flag = common_interface.select_name(type, teacher_name)
 82         if flag:
 83             print('账号已存在,请重新输入')
 84         else:
 85             # 选择学校
 86             school_name = common_interface.select_type_class('school')
 87             flag, msg = admin_interface.create_teacher(admin_name,school_name,teacher_name)
 88             if flag:
 89                 print(msg)
 90 
 91             else:
 92                 print(msg)
 93                 continue
 94 # \n5.创建课程
 95 @common.login_auth
 96 def create_course():
 97     from core import src
 98     admin_name = src.user_info['name']
 99     # 输入查询类型
100     school_name = common_interface.select_type_class('school')
101     while True:
102         name = input("course_name>>>:").strip()
103         type = 'Course'
104         flag = common_interface.select_name(name, type)
105         if flag:
106             print('课程存在')
107         else:
108             if name == 'q': return
109             price = input("price>>>:").strip()
110             if price == 'q': return
111             cycle = input("cycle>>>:").strip()
112             if cycle == 'q': return
113             flag, msg = admin_interface.create_course(school_name, admin_name, name, price, cycle)
114             if flag:
115                 print(msg)
116                 continue
117             else:
118                 print(msg)
119                 continue
120 # \n6.创建班级
121 @common.login_auth
122 def create_classes():
123     from core import src
124     admin_name = src.user_info['name']
125     # 输入查询类型
126     school_name = common_interface.select_type_class('school')
127     while True:
128         classes_name = input("classes_name>>>:").strip()
129         if classes_name == 'q': return
130         type = 'classes'
131         flag = common_interface.select_name(type,classes_name)
132         if flag:
133             print('班级已经存在')
134         else:
135             flag, msg = admin_interface.create_classes(school_name, admin_name, classes_name)
136             if flag:
137                 print(msg)
138                 continue
139             else:
140                 print(msg)
141                 continue
142 # \n7.关联讲师-课程-班级
143 @common.login_auth
144 def choose_teacher_course_classes():
145     from core import src
146     admin_name = src.user_info['name']
147     while True:
148         # 管理员找学校
149         school_name = common_interface.select_type_class('school')
150         flag1,msg1 = admin_interface.admin_choose_school(admin_name,school_name)
151         if flag1:
152             print(msg1)
153         else:
154             print(msg1)
155         # 学校找老师
156         teacher_name = common_interface.select_type_class('teacher')
157         flag2, msg2 = admin_interface.school_choose_teacher(school_name,teacher_name)
158         if flag2:
159             print(msg2)
160         else:
161             print(msg2)
162         # 老师选课程
163         course_name = common_interface.select_type_class('course')
164         flag3, msg3 = admin_interface.teacher_choose_course(teacher_name,course_name)
165         if flag3:
166             print(msg3)
167         else:
168             print(msg3)
169         # 课程定班级
170         classes_name = common_interface.select_type_class('classes')
171         flag4, msg4 = admin_interface.course_choose_classes(course_name,classes_name)
172         if flag4:
173             print(msg4)
174             break
175         else:
176             print(msg4)
177 # \n8.注销
178 @common.login_auth
179 def logout():
180     # 注销
181     from core import src
182     name = src.user_info['name']
183     type = src.user_info['type']
184     msg = common_interface.logout(type, name)
185     print(msg)
186 func_dic = {
187     "1":register,
188     "2":login,
189     "3":create_school,
190     "4":create_teacher,
191     "5":create_course,
192     "6":create_classes,
193     "7":choose_teacher_course_classes,
194     "8":logout,
195 }
196 def run():
197     print("welcome to admin view!!!")
198     while True:
199         print("""\n1.注册\n2.登录\n3.创建校区\n4.创建讲师\n5.创建课程\n6.创建班级\n7.关联讲师-课程-班级\n8.注销q.quit\n""")
200         choose = input("choose(q.quit)>>>:").strip()
201         if choose == 'q':
202             return
203         elif choose in func_dic:
204             func_dic[choose]()
205         else:
206             print('choose not in func_dic!!!')
207             continue
admin.py

 

src.py

选课系统 -- # 25 -26
 1 from core import admin,teacher,student
 2 
 3 # 保存登录状态
 4 user_info = {
 5     'name':None,
 6     'type':None
 7 }
 8 
 9 func_dic = {
10     "1":admin.run,
11     "2":teacher.run,
12     "3":student.run,
13 }
14 
15 def run():
16     print('welcome to choose course !!!')
17     while True:
18         print("""\n1.管理员视图\n2.老师视图\n3.学生视图\nq.quit\n""")
19         choose = input("choose(q.quit)>>>:").strip()
20         if choose == 'q':return
21         elif choose in func_dic:
22             func_dic[choose]()
23         else:
24             print('choose not in func_dic!!!')
25             continue
src

 

student.py

选课系统 -- # 25 -26
 1 from interface import common_interface,student_interface
 2 from lib import common
 3 # 1.注册
 4 def register():
 5     while True:
 6         name = input("admin_name>>>:").strip()
 7         type = 'student'
 8         flag = common_interface.select_name(type,name)
 9         if flag:
10             print('账号已存在,请重新输入')
11         else:
12             pwd = input("pwd>>>:").strip()
13             re_pwd = input("re_pwd>>>:").strip()
14             if pwd and re_pwd:
15                 if pwd == re_pwd:
16                     # 调用接口层
17                     msg = common_interface.register_interface(type,name,pwd)
18                     if msg:
19                         print(msg)
20                         break
21                 else:
22                     print("两次密码不一致")
23             else:
24                 print("密码和验证密码不可为空")
25 # 2.登录
26 def login():
27     while True:
28         name = input("name>>>:").strip()
29         type = 'student'
30         flag = common_interface.select_name(type,name)
31         if flag:
32             print('账号输入正确,请输入密码')
33             pwd = input("pwd>>>:").strip()
34             if pwd:
35                 # 调用接口层
36                 flag,msg = common_interface.login_interface(type, name, pwd)
37                 if flag:
38                     print(msg)
39                     from core import src
40                     src.user_info['name'] = name
41                     src.user_info['type'] = type
42                     break
43                 else:
44                     print(msg)
45             else:
46                 print("密码不可为空")
47         else:
48             print('账户输入错误')
49 # \n3.选课
50 @common.login_auth
51 def choose_stu_course():
52     from core import src
53     student_name = src.user_info['name']
54     school_name = common_interface.select_type_class('school')
55     course_name = common_interface.select_type_class('course')
56     msg = student_interface.choose_student_course_interface(student_name, school_name, course_name)
57     print(msg)
58 # \n4.交学费
59 @common.login_auth
60 def buy_course():
61     from core import src
62     student_name = src.user_info['name']
63     # 班级
64     classes_name = common_interface.select_type_class('classes')
65 
66     # 课程
67     course_name = common_interface.select_type_class('course')
68 
69     # 价格
70     price = student_interface.course_price_interface(course_name)
71     print(price)
72     # 支付
73     msg = student_interface.is_buy_student_interface(student_name,course_name,classes_name)
74     print(msg)
75 # \n5.查看自己的分数
76 @common.login_auth
77 def select_score():
78     from core import src
79     student_name = src.user_info['name']
80     msg = student_interface.select_score_student_interface(student_name)
81     print(msg)
82 # \n6.注销
83 @common.login_auth
84 def logout():
85     from core import src
86     name = src.user_info['name']
87     type = src.user_info['type']
88     msg = common_interface.logout(type, name)
89     print(msg)
90 func_dic = {
91     "1":register,
92     "2":login,
93     "3":choose_stu_course,
94     "4":buy_course,
95     "5":select_score,
96     "6":logout,
97 }
student.py

teacher.py

选课系统 -- # 25 -26
 1 from interface import common_interface,teacher_interface
 2 from lib import common
 3 
 4 # 1.登录
 5 def login():
 6     while True:
 7         name = input("name>>>:").strip()
 8         type = 'teacher'
 9         flag = common_interface.select_name(type,name)
10         if flag:
11             print('账号输入正确,请输入密码')
12             pwd = input("pwd>>>:").strip()
13             if pwd:
14                 # 调用接口层
15                 flag,msg = teacher_interface.login_interface(type, name, pwd)
16                 if flag:
17                     print(msg)
18                     from core import src
19                     src.user_info['name'] = name
20                     src.user_info['type'] = type
21                     break
22                 else:
23                     print(msg)
24             else:
25                 print("密码不可为空")
26         else:
27             print('账户输入错误')
28 # \n2.选择班级
29 @common.login_auth
30 def choose_classes():
31     # 校区
32     school_name = common_interface.select_type_class('school')
33     # 课程:
34     course_name = common_interface.select_type_class('course')
35     # 班级
36     classes_name = common_interface.select_type_class('classes')
37     msg = teacher_interface.choose_classes_interface(school_name,course_name,classes_name)
38     print(msg)
39 # \n3.修改学员成绩
40 @common.login_auth
41 def update_score():
42     while True:
43         student_name = input("student_name>>>:").strip()
44         student_score = input("student_score>>>").strip()
45         if student_score.isdigit():
46             student_score = int(student_score)
47             msg = teacher_interface.select_interface_student(student_name,student_score)
48             print(msg)
49             break
50         else:
51             print('成绩必需为数字')
52 # \n4.查看学员信息
53 @common.login_auth
54 def select_student_info():
55     while True:
56         student_name = input("student_name>>>:").strip()
57         msg = teacher_interface.student_info_interface(student_name)
58         print(msg)
59         break
60 # \n5.注销
61 @common.login_auth
62 def logout():
63     from core import src
64     name = src.user_info['name']
65     type = src.user_info['type']
66     msg = common_interface.logout(type, name)
67     print(msg)
68 
69 func_dic = {
70     "1":login,
71     "2":choose_classes,
72     "3":update_score,
73     "4":select_student_info,
74     "5":logout,
75 }
76 def run():
77     print("welcome to admin view!!!")
78     while True:
79         print("""\n1.登录\n2.选择班级\n3.修改学员成绩\n4.查看学员信息\n5.注销\nq.quit\n""")
80         choose = input("choose(q.quit)>>>:").strip()
81         if choose == 'q':
82             return
83         elif choose in func_dic:
84             func_dic[choose]()
85         else:
86             print('choose not in func_dic!!!')
87             continue
teacher.py

 

接口层

interface

admin_interface.py

选课系统 -- # 25 -26
  1 from db.modul import *
  2 from lib import common
  3 # 创建学校
  4 def create_school_interface(admin_name,name,addr):
  5     school = School.select(name)
  6     if school:
  7         return False,f'{name}学校存在'
  8     else:
  9         admin = Admin.select(admin_name)
 10         if admin:
 11             admin.add_school(name,addr)
 12             return True,f'{name}学校创建成功'
 13         else:
 14             return False,'管理员不可能不存在,逻辑有问题,重试'
 15 
 16 # 创建老师
 17 def create_teacher(admin_name,school_name,teacher_name):
 18     # pwd = common.get_pwd(pwd)
 19     teacher = Teacher.select(teacher_name)
 20     if teacher:
 21         return False, f'{teacher_name}老师存在'
 22     else:
 23         admin = Admin.select(admin_name)
 24         if admin:
 25             admin.add_teacher(teacher_name,school_name)
 26             return True, f'{teacher_name}老师创建成功'
 27         else:
 28             return False, '管理员不可能不存在,逻辑有问题,重试'
 29 # 创建课程
 30 def create_course(school_name,admin_name,name,price,cycle):
 31         school = School.select(school_name)
 32         if school:
 33             admin = Admin.select(admin_name)
 34             admin.add_course(name,price,cycle)
 35             return True, f'{name}课程创建成功'
 36         else:
 37             print( f'{school_name}学校不存在,去创建学校')
 38             from core import admin
 39             admin.create_school()
 40             print('创建完成,重新选择')
 41 
 42 # 创建班级
 43 def create_classes(school_name,admin_name,name):
 44 
 45         school = School.select(school_name)
 46         if school:
 47             admin = Admin.select(admin_name)
 48             admin.add_classes(name)
 49             return True, f'{name}班级创建成功'
 50         else:
 51             print( f'{school_name}学校不存在,去创建学校')
 52             from core import admin
 53             admin.create_school()
 54             print('创建完成,重新选择')
 55 
 56 # 关联管理员和学校
 57 def admin_choose_school(admin_name,school_name):
 58     admin = Admin.select(admin_name)
 59     # if admin.school_list == school_name:
 60     # for name in admin.school_list:
 61     #     if school_name == name:
 62     #         msg = f'{school_name}学校已经在管理员名下'
 63     #         return False,msg
 64     #     else:
 65     admin.admin_choose_school(school_name)
 66     return True,f'添加{school_name}学校到管理员名下'
 67 
 68 
 69 # 关联学校和老师
 70 def school_choose_teacher(school_name,teacher_name):
 71     school = School.select(school_name)
 72     # if school:
 73     #
 74     #     old_teacher_list = School.teacher_list
 75     #     for name in old_teacher_list:
 76     #         if teacher_name == name:
 77     #             msg = f'{teacher_name}学校已经在管理员名下'
 78     #             return False,msg
 79     #         else:
 80     #
 81     #             return True,f'添加{teacher_name}学校到管理员名下'
 82     # else:
 83     #     from core import admin
 84     #     admin.create_school()
 85     school.school_choose_teacher(teacher_name)
 86     return True, f'添加{teacher_name}老师到学校名下'
 87 # 关联老师和课程
 88 def teacher_choose_course(teacher_name,course_name):
 89     teacher = Teacher.select(teacher_name)
 90     # if teacher:
 91     #     old_course_list = Teacher.course_list
 92     #     for name in old_course_list:
 93     #         if teacher_name == name:
 94     #             msg = f'{course_name}学校已经在管理员名下'
 95     #             return False,msg
 96     #         else:
 97     #             old_course_list.append(course_name)
 98     #             return True,f'添加{teacher_name}学校到管理员名下'
 99     # else:
100     #     from core import admin
101     #     admin.create_teacher()
102     teacher.teacher_choose_course(course_name)
103     return True, f'添加{course_name}课程到老师名下'
104 # 关练课程和班级
105 def course_choose_classes(course_name,classes_name):
106     course = Course.select(course_name)
107     # if course:
108     #
109     #     old_course_list = Course.classes_list
110     #     for name in old_course_list:
111     #         if classes_name == name:
112     #             msg = f'{classes_name}学校已经在管理员名下'
113     #             return False,msg
114     #         else:
115     #             old_course_list.append(classes_name)
116     #             return True,f'添加{classes_name}学校到管理员名下'
117     # else:
118     #     from core import admin
119     #     admin.create_course()
120     course.course_choose_classes(classes_name)
121     return True, f'添加{classes_name}班级到课程名下'
admin_interface

common_interface.py

选课系统 -- # 25 -26
  1 from db.modul import *
  2 from lib import common
  3 
  4 # 查询账号是否存在
  5 def select_name(type,name):
  6     if type == 'admin':
  7         admin = Admin.select(name)
  8         if admin:
  9             return True
 10     if type == 'teacher':
 11         teacher = Teacher.select(name)
 12         if teacher:
 13             return True
 14     if type == 'student':
 15         student = Student.select(name)
 16         if student:
 17             return True
 18     if type == 'school':
 19         school = School.select(name)
 20         if school:
 21             return True
 22     if type == 'course':
 23         course = Course.select(name)
 24         if course:
 25             return True
 26     if type == 'classes':
 27         classes = Classes.select(name)
 28         if classes:
 29             return True
 30     else:
 31         return False
 32 # 注册
 33 def register_interface(type,name,pwd):
 34     pwd = common.get_pwd(pwd)
 35     if type == 'admin':
 36         admin = Admin(name,pwd)
 37         admin.save()
 38         return f"{name}注册完成"
 39     if type == 'student':
 40         student = Student(name,pwd)
 41         student.save()
 42         return f"{name}注册完成"
 43     else:
 44         return False
 45 # 登录
 46 def login_interface(type,name,pwd):
 47     pwd = common.get_pwd(pwd)
 48     if type == 'admin':
 49         admin = Admin.select(name)
 50         if admin.pwd == pwd:
 51             msg = f'{name}登陆成功'
 52             return True,msg
 53         else:
 54             return False,f'{name}密码错误'
 55     if type == 'student':
 56         student = Student.select(name)
 57         if student.pwd == pwd:
 58             msg = f'{name}登陆成功'
 59             return True, msg
 60         else:
 61             return False, f'{name}密码错误'
 62     else:
 63         return False,False
 64 # 注销
 65 def logout(type,name):
 66     from core import src
 67     src.user_info['name'] = None
 68     src.user_info['type'] = None
 69     return f"{type}/{name}账号注销成功"
 70 # 查询所有
 71 # 查看admin/teacher/student/school/course/classes所有的信息
 72 def selct_all_name(type):
 73     if type == 'school':
 74         name_list = School.select_all()
 75         res = []
 76         for names in name_list:
 77             res.append(names.name)
 78         return res
 79     if type == 'course':
 80         name_list = Course.select_all()
 81         res = []
 82         for names in name_list:
 83             res.append(names.name)
 84         return res
 85     if type == 'classes':
 86         name_list = Classes.select_all()
 87         res = []
 88         for names in name_list:
 89             res.append(names.name)
 90         return res
 91     if type == 'teacher':
 92         name_list = Teacher.select_all()
 93         res = []
 94         for names in name_list:
 95             res.append(names.name)
 96         return res
 97 
 98     if type == 'student':
 99         name_list = Student.select_all()
100         res = []
101         for names in name_list:
102             res.append(names.name)
103         return res
104     if type == 'admin':
105         name_list = Admin.select_all()
106         res = []
107         for names in name_list:
108             res.append(names.name)
109         return res
110 
111 def select_type_class(type):
112     while True:
113         # type = input("type(admin/teacher/student/school/course/classes)>>>:").strip()
114         name_list = selct_all_name(type)
115         for name in enumerate(name_list, start=1):
116             print(name)
117         choose = input("choose>>>:").strip()
118         if choose.isdigit():
119             choose = int(choose)
120             if choose in range(1,len(name_list)+1):
121                 type_name = name_list[choose-1]
122                 return type_name
123             else:
124                 print('超出范围')
125 
126         else:
127             print("choose必须为数字")
128             continue
common_inteaface

 


student_interface.py
teacher_interface.py

公共层

lib

commom

配置层

conf

settings

 

数据库

db

db_hangdler

modul

补充:日志

log

log_log

lib

common

上一篇:CF1333D Challenges in school №41(思维)


下一篇:codeforces-1333D-Challenges in school №41