tree .
.
├── bin
│   ├── __init__.py
│   └── start.py #启动文件
├── conf
│   ├── __init__.py
│   └── settings.py #全局配置文件
├── core#核心代码目录
│   ├── CourseClass.py#课程类
│   ├── GradeClass.py #班级类
│   ├── __init__.py
│   ├── main.py #主程序
│   ├── RWdb.py #数据读写功能类
│   ├── SchoolClass.py #学校类
│   ├── SchoolPeopleClass.py #人员父类
│   ├── StudentsClass.py #学生类
│   └── TeacherClass.py #教师类
├── db #存放各种对象数据
│   ├── course.db
│   ├── grade.db
│   ├── __init__.py
│   ├── school.db
│   ├── students.db
│   └── teachers.db
├── __init__.py
└── test#测试目录
├── __init__.py
└── test.py

目录结构

#!/usr/bin/env python
# Author:Zhangmingdad
import os
BASER_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__) )) '''数据库文件路径/文件名配置'''
DB_PATH = os.path.join(BASER_DIR,'db')
SCHOOL_DB_FILE = os.path.join(DB_PATH,'school.db')
COURSE_DB_FILE = os.path.join(DB_PATH,'course.db')
TEACHERS_DB_FILE = os.path.join(DB_PATH,'teachers.db')
STUDENTS_DB_FILE = os.path.join(DB_PATH,'students.db')
GRADE_DB_FILE = os.path.join(DB_PATH,'grade.db') '''系统统一入口视图配置'''
login_sys = {
'1':'manager_sys()',
'2':'students_sys()',
'3':'teachers_sys()'
}
smg_login_sys = '''
【1】 学校管理系统
【2】 学生注册缴费查询系统
【3】 教师办公系统
'''
'''后台管理视图配置'''
manager_sys = {
'1':'create_course()',
'2':'create_teacher()',
'3':'create_grade()',
'4':'create_school()',
'5':'review_school_info()'
}
smg_manager_sys = '''
【1】 创建课程
【2】 招聘老师
【3】 创建班级
【4】 创建学校
【5】 查看学校详情
''' students_sys = {
'1':'student_sign_in()',
'2':'stu_paytuition()',
'3':'show_score()',
'4':'show_stu_info()'
}
smg_students_sys = '''
【1】 注册
【2】 缴费
【3】 成绩查询
【4】 查看个人信息
''' teachers_sys = {
'1':'show_teach_grades()',
'2':'show_grade_students()',
'3':'modify_stu_score()',
'4':'show_teacher_info()'
}
smg_teachers_sys = '''
【1】 查看所教班级
【2】 查看班级学员列表
【3】 修改学生成绩
【4】 查看教师个人信息
''' Manager_user = 'root'
Manager_passwd = 'root'

settings.py

#!/usr/bin/env python
# Author:Zhangmingda
import os,pickle
from conf import settings class RWdb(object):
'''数据读写大类'''
@staticmethod
def readschooldb():
'''通过pickle的load方法读取学校信息'''
if os.path.exists(settings.SCHOOL_DB_FILE):
with open(settings.SCHOOL_DB_FILE,'rb') as school_f:
school_info = pickle.load(school_f)
else:
school_info = {}
return school_info
@staticmethod
def writeschooldb(school_info):
'''通过pickle的dump存入学校信息'''
with open(settings.SCHOOL_DB_FILE,'wb') as school_f:
pickle.dump(school_info,school_f)
#################课程读写#################################
@staticmethod
def readcoursedb():
'''通过pickle的load方法读取课程信息'''
if os.path.exists(settings.COURSE_DB_FILE):
with open(settings.COURSE_DB_FILE,'rb') as course_f:
course_info = pickle.load(course_f)
else:
course_info = {}
return course_info
@staticmethod
def writecoursedb(course_info):
'''通过pickle的dump存入学校信息'''
with open(settings.COURSE_DB_FILE,'wb') as course_f:
pickle.dump(course_info,course_f)
#################班级数据读写#################################
@staticmethod
def readgradedb():
'''通过pickle的load方法读取课程信息'''
if os.path.exists(settings.GRADE_DB_FILE):
with open(settings.GRADE_DB_FILE,'rb') as grade_f:
grade_info = pickle.load(grade_f)
else:
grade_info = {}
return grade_info
@staticmethod
def writegradedb(grade_info):
'''通过pickle的dump存入学校信息'''
with open(settings.GRADE_DB_FILE,'wb') as grade_f:
pickle.dump(grade_info,grade_f)
#################教师数据读写#################################
@staticmethod
def readteachersdb():
'''通过pickle的load方法读取课程信息'''
if os.path.exists(settings.TEACHERS_DB_FILE):
with open(settings.TEACHERS_DB_FILE,'rb') as teachers_f:
teachers_info = pickle.load(teachers_f)
else:
teachers_info = {}
return teachers_info
@staticmethod
def writeteachersdb(teachers_info):
'''通过pickle的dump存入学校信息'''
with open(settings.TEACHERS_DB_FILE,'wb') as teachers_f:
pickle.dump(teachers_info,teachers_f)
#################学生数据读写#################################
@staticmethod
def readstudentsdb():
'''通过pickle的load方法读取课程信息'''
if os.path.exists(settings.STUDENTS_DB_FILE):
with open(settings.STUDENTS_DB_FILE,'rb') as students_f:
students_info = pickle.load(students_f)
else:
students_info = {}
return students_info
@staticmethod
def writestudentsdb(students_info):
'''通过pickle的dump存入学校信息'''
with open(settings.STUDENTS_DB_FILE,'wb') as students_f:
pickle.dump(students_info,students_f)

RWdb.py

#!/usr/bin/env python
# Author:Zhangmingda
import os,sys
BASER_DIR = os.path.dirname(os.path.abspath(__file__) )
sys.path.append(BASER_DIR)
from .SchoolClass import School
from conf import settings
def create_school():
'''创建一个学校'''
back_flag = False
while not back_flag:
school_dict = School.readschooldb()
'''查看已有学校名字'''
if len(school_dict):
print('当前已存在学校如下:')
for school_name in school_dict:
print(school_name)
'''新建学校名字'''
new_school_name = input('请输入要创建的学校名称(b返回):').strip()
if new_school_name in school_dict or new_school_name == '':
print('\033[31;1m您要创建的学校名称不合法或已存在!请重新输入\033[0m')
elif new_school_name == 'b':
back_flag = True
else:
'''创建学校'''
School(new_school_name)
print('\033[32;1m创建学校:%s OK!\033[0m'%new_school_name)
chose_func = input('继续创建输入yes|任意键退出:')
if chose_func == 'yes':
continue
else:
back_flag = True def review_school_info():
'''查看学校信息'''
def show_school_students(sch_obj):
print('本校学生共计:%s人' % len(sch_obj.school_students))
for student in sch_obj.school_students:
print(student)
def show_school_teachers(sch_obj):
print('本校老师共计:%s人'% len(sch_obj.school_teachers))
for teacher in sch_obj.school_teachers:
print(teacher)
def show_school_grades(sch_obj):
print('本校设置班级共计:%s个' % len(sch_obj.school_grades))
for grade in sch_obj.school_grades:
print(grade)
while True:
school_dict = School.readschooldb()
'''查看已有学校名字'''
if len(school_dict):
print('当前已存在学校如下:')
for school_name in school_dict:
print(school_name)
school_name = input('请输入要查询学校名称:').strip()
if school_name in school_dict:
print('%s 校区 详情如下:'.center(50,'#')% school_name)
sch_obj = school_dict[school_name]
show_school_students(sch_obj)
show_school_teachers(sch_obj)
show_school_grades(sch_obj)
print('%s 校区详情查询完毕'.center(50, '#')% school_name)
else:
print('\033[31;1m输入的学校名称不存在,请重新输入\033[0m')
continue
chose_continue = input("继续查询,输入y| 其它任意键退出")
if chose_continue == 'y':
continue
else:
break
else:
print('\033[31;1m当前没有任何学校\033[0m')
break def create_course():
'''创建课程'''
while True:
school_dict = School.readschooldb()
'''查看已有学校名字'''
if len(school_dict):
print('\033[34;1m请选择在哪个校区开设课程:\033[0m')
for school_name in school_dict:
print(school_name)
'''选择学校名字'''
chose_school = input('\033[34;1m请输入选择的学校名称|b退出:\033[0m').strip()
if chose_school == 'b':
break
if chose_school in school_dict:
sch_obj = school_dict[chose_school]
sch_obj.create_course() #学校实例的创建课程方法
break
else:
print('\033[31;1m您输入的学校名不存在,请重新输入\033[0m') def create_teacher():
'''创建老师'''
while True:
school_dict = School.readschooldb()
'''查看已有学校名字'''
if len(school_dict):
print('\033[34;1m为哪个校区招聘老师:\033[0m')
for school_name in school_dict:
print(school_name)
'''选择学校名字'''
chose_school = input('\033[34;1m请输入选择的学校名称|b退出:\033[0m').strip()
if chose_school == 'b':
break
if chose_school in school_dict:
sch_obj = school_dict[chose_school]
sch_obj.create_teacher() #通过学校实例的创建老师方法
break
else:
print('\033[31;1m您输入的学校名不存在,请重新输入\033[0m') def create_grade():
while True:
school_dict = School.readschooldb()
'''查看已有学校名字'''
if len(school_dict):
print('\033[34;1m要在哪个校区增设班级:\033[0m')
for school_name in school_dict:
print(school_name)
'''选择学校名字'''
chose_school = input('\033[34;1m请输入选择的学校名称|b退出:\033[0m').strip()
if chose_school == 'b':
break
if chose_school in school_dict:
sch_obj = school_dict[chose_school]
sch_obj.create_grade()
break
else:
print('\033[31;1m您输入的学校名不存在,请重新输入\033[0m') def manager_sys():
'''后台管理系统'''
login_status = False
while not login_status:
manager_user = input('输入管理员用户名:').strip()
manager_passwd = input('输入管理员密码:').strip()
if manager_user == settings.Manager_user and manager_passwd == settings.Manager_passwd:
login_status = True
else:
print('\033[31;1m管理员用户名或密码错误\033[0m')
break
else:
while True:
print('欢迎进入\033[32;1m选课后台管理\033[0m系统'.center(50, '#'))
print(settings.smg_manager_sys)
chose_func = input('请输入要选择的功能序号|b退出:').strip()
if chose_func == 'b':
break
if chose_func in settings.manager_sys:
eval(settings.manager_sys[chose_func])
else:
print('\033[31;1m您输入的功能序号不存在,请重新输入\033[0m') def students_sys(): def student_sign_in():
'''学生注册系统'''
while True:
school_dict = School.readschooldb()
'''查看已有学校名字'''
if len(school_dict):
print('\033[34;1m请选择在哪个校区注册:\033[0m')
for school_name in school_dict:
print(school_name)
chose_school = input('\033[34;1m请输入选择的学校名称|b退出:\033[0m').strip()
if chose_school == 'b':
break
if chose_school in school_dict:
sch_obj = school_dict[chose_school]
sch_obj.add_student() #通过学校实例添加学员
break
else:
print('\033[31;1m您输入的学校名不存在,请重新输入\033[0m') def stu_auth(func):
'''学生登录认证装饰器'''
def stu_login(*args):
while True:
stu_name = input('请输入学员姓名|b退出:').strip()
if stu_name in School.readstudentsdb():
stu_obj = School.readstudentsdb()[stu_name]
while True:
stu_passwd = input('请输入密码|b退出:').strip()
if stu_passwd == stu_obj.passwd:
func(stu_obj)
break
elif stu_passwd == 'b':
print('\033[31;1m退出登录\033[0m')
break
else:
print('\033[31;1m密码错误\033[0m')
break
elif stu_name == 'b':
print('\033[31;1m退出登录\033[0m')
break
else:
print('\033[31;1m学生姓名不存在,请重新输入...\033[0m')
return stu_login
@stu_auth
def stu_paytuition(stu_obj):
'''使用学生对象交学费'''
stu_obj.paytuition()
@stu_auth
def show_score(stu_obj):
'''查看学生成绩'''
stu_obj.show_score()
@stu_auth
def show_stu_info(stu_obj):
'''查看个人信息'''
stu_obj.student_info() while True:
print('欢迎进入\033[32;1m欢迎进入学生自助缴费注册查询系统\033[0m'.center(50, '#'))
print(settings.smg_students_sys)
chose_func = input('请输入要选择的功能序号|b退出:').strip()
if chose_func == 'b':
break
if chose_func in settings.students_sys:
while True:
eval(settings.students_sys[chose_func])
chose_continue = input('继续?(yes继续|任意键退出)').strip()
if chose_continue != 'yes':
break
else:
print('\033[31;1m您输入的功能序号不存在,请重新输入\033[0m') def teachers_sys():
'''老师功能系统'''
teacher_auth_status = False
# teacher_obj = None def auth_teacher(func):
'''检查教师登录状态装饰器'''
def teacher_login(*args):
if teacher_auth_status:
func()
return teacher_login
@auth_teacher
def show_teach_grades():
print('查看所教班级信息'.center(40,'#'))
teacher_obj.show_teach_grades()
@auth_teacher
def show_grade_students():
print('查看学员列表选择班级'.center(40,'#'))
teacher_obj.show_grade_students()
@auth_teacher
def modify_stu_score():
'''修改学员成绩'''
show_teach_grades(teacher_obj)
print('修改学员成绩信息'.center(40, '#'))
chose_grade = input('\033[31;1m请选择班级\033[0m').strip()
while chose_grade in teacher_obj.teach_grade:
grade_obj = School.readgradedb()[chose_grade]
print('当前班级(%s)学员如下:' % chose_grade)
for student in grade_obj.students:
print(student)
while True:
chose_student_name = input('\033[32;1m请选择学员|b退出\033[0m').strip()
if chose_student_name in grade_obj.students:
student_obj = grade_obj.students[chose_student_name]
score_name = input('\033[32;1m请输入科目名称:\033[0m').strip()
score = input('\033[32;1m请输入科目成绩:\033[0m').strip()
student_obj.score[score_name] = score
'''存储学生数据'''
students_info = student_obj.readstudentsdb()
students_info[chose_student_name] = student_obj
student_obj.writestudentsdb(students_info)
print('\033[32;1m成绩修改成功!\033[0m')
'''存储到班级数据中'''
grade_info = student_obj.readgradedb()
grade_info[student_obj.stu_grade].students[student_obj.name] = student_obj
student_obj.writegradedb(grade_info)
'''存储到学校数据中'''
school_info = student_obj.readschooldb()
'''更新学校班级数据(中的学生数据)'''
school_info[student_obj.stu_school].school_grades[student_obj.stu_grade].students[
student_obj.name] = student_obj
'''更新学校对象中的学生数据'''
school_info[student_obj.stu_school].school_students[student_obj.name] = student_obj
student_obj.writeschooldb(school_info)
# break
elif chose_student_name == 'b':
break
else:
print('\033[31;1m输入的学生姓名不存在,请重新输入\033[0m')
break
else:
print('\033[31;1m您选择的班级不存在\033[0m')
@auth_teacher
def show_teacher_info():
teacher_obj.teacher_info() while True:
'''登录认证循环体,保证任何一步不进入死循环'''
teacher_name = input('请输入老师姓名|b退出:').strip()
teachers_info = School.readteachersdb()
if teacher_name in teachers_info:
teacher_obj = teachers_info[teacher_name]
while True:
teacher_passwd = input('请输入密码|b退出:').strip()
if teacher_passwd == teacher_obj.passwd:
teacher_auth_status = True
break
elif teacher_passwd == 'b':
print('\033[31;1m退出登录\033[0m')
break
else:
print('\033[31;1m密码错误,请重新输入...\033[0m')
break
elif teacher_name == 'b':
print('\033[31;1m退出登录\033[0m')
break
else:
print('\033[31;1m教师姓名不存在,请重新输入...\033[0m') while teacher_auth_status:
print('欢迎进入\033[32;1m欢迎进入教师管理系统\033[0m'.center(50, '#'))
print(settings.smg_teachers_sys)
chose_func = input('请输入要选择的功能序号|b退出:').strip()
if chose_func == 'b':
break
if chose_func in settings.teachers_sys:
while True:
eval(settings.teachers_sys[chose_func])
chose_continue = input('继续?(yes继续|任意键退出当前功能模块)').strip()
if chose_continue != 'yes':
break
else:
print('\033[31;1m您输入的功能序号不存在,请重新输入\033[0m') def login_sys():
'''登录总入口'''
while True:
print('欢迎进入老男孩\033[32;1m学校选课系统\033[0m'.center(50, '#'))
print(settings.smg_login_sys)
chose_sub_sys = input('请输入要进入的子系统序号|b退出:').strip()
if chose_sub_sys == 'b':
break
if chose_sub_sys in settings.login_sys:
eval(settings.login_sys[chose_sub_sys])
else:
print('\033[31;1m您输入的系统序号不存在,请重新输入\033[0m')

main.py

#!/usr/bin/env python
# Author:Zhangmingda
from SchoolPeopleClass import People
from RWdb import RWdb class Student(People,RWdb):
'''定义学生角色应有的属性和方法'''
def __init__(self,name,passwd,age,sex,stu_grade,school):
super(Student,self).__init__(name,passwd,age,sex)
self.stu_grade = stu_grade
self.tuition = self.readcoursedb()[self.readgradedb()[stu_grade].course_name].price
self.payment_status = '未缴'
self.stu_school = school
self.score = {}
'''存储学生数据'''
students_info = self.readstudentsdb()
students_info[self.name] = self
self.writestudentsdb(students_info) def paytuition(self):
'''学生交学费方法'''
if self.payment_status == True:
print('\033[31;1m学费已交!无需再交\033[0m')
else:
while True:
print('您所在班级,所需缴费金额为:%s 元'% self.tuition)
pay_tuition = input('输入要缴费的金额:').strip()
if pay_tuition.isnumeric() and int(pay_tuition) >= self.tuition:
self.payment_status = '已缴'
'''缴费后重新存储学生数据'''
students_info = self.readstudentsdb()
students_info[self.name] = self
self.writestudentsdb(students_info)
print('\033[31;1m缴费成功!\033[0m')
'''存储到班级数据中'''
grade_info = self.readgradedb()
grade_info[self.stu_grade].students[self.name] = self
self.writegradedb(grade_info) '''存储到学校数据中'''
school_info = self.readschooldb()
'''更新学校班级数据(中的学生数据)'''
school_info[self.stu_school].school_grades[self.stu_grade].students[self.name] = self
'''更新学校对象中的学生数据'''
school_info[self.stu_school].school_students[self.name] = self
self.writeschooldb(school_info)
break elif pay_tuition == 'b':
print('\033[32;1m您放弃了缴费\033[0m')
break
else:
print('\033[32;1m金额不足|输入错误,请重缴!\033[0m') def show_score(self):
'''查看学生成绩'''
if len(self.score):
print('\033[33;1m学员:%s成绩如下\033[0m'.center(50,'#')% self.name)
for score_name in self.score:
print('\033[32;1m科目:%s\t成绩:%s\033[0m'% (score_name,self.score[score_name]))
else:
print('\033[31;1m当前没有任何成绩可以查询\033[0m') def student_info(self):
'''查看学生个人信息'''
stu_info = '''
姓名:%s
年龄:%s
性别:%s
所在班级:%s
所在学校:%s
应缴学费:%s
缴费状态:%s'''%(self.name,self.age,self.sex,self.stu_grade,self.stu_school,self.tuition,self.payment_status)
print('\033[33;1m:%s 你好,您的个人信息如下\033[0m'.center(50,'#')% self.name)
print(stu_info)

StudentsClass.py

#!/usr/bin/env python
# Author:Zhangmingda from RWdb import RWdb
from CourseClass import Course
from GradeClass import Grade
from TeacherClass import Teacher
from StudentsClass import Student class School(RWdb):
def __init__(self,name):
self.school_name = name
self.school_course = {}
self.school_teachers = {}
self.school_students = {}
self.school_grades = {}
school_info = self.readschooldb()
school_info[self.school_name] = self
self.writeschooldb(school_info) def create_course(self):
'''管理员创建课程'''
while True:
if len(self.school_course):
print('当前本校已开设课程:')
for course_name in self.school_course:
print(course_name)
new_course_name = input('请输入要创建的课程名称(b退回):').strip()
if new_course_name in self.school_course or new_course_name == '':
print('\033[31;1m您要创建的课程已存在或不合法!请重新输入\033[0m')
continue
elif new_course_name == 'b':
break
else:
while True :
price = input('输入课程价格:').strip()
if price.isnumeric():
price = int(price)
break
else:
print("\033[31;1m课程价格必须为纯数字,请重新输入....\033[0m")
preiod = input('计划课程周期:').strip()
new_course = Course(new_course_name,price,preiod)
school_info = self.readschooldb()
self.school_course[new_course_name] = new_course
school_info[self.school_name] = self
self.writeschooldb(school_info)
print('\033[32;1m创建课程:%s OK!\033[0m' % new_course_name)
# break def create_teacher(self):
'''管理员创建老师'''
while True:
teachers_info = self.school_teachers
'''当前校区已存在老师名单:'''
if len(teachers_info):
print('当前学校已招聘老师名单:')
for school_teacher in teachers_info:
print(school_teacher)
new_teacher_name = input('输入要新招聘的老师名字(b退出):').strip()
if new_teacher_name in teachers_info or new_teacher_name == '':
print('\033[31;1m该老师已经存在(或不合法),请重新输入~\033[0m')
continue
elif new_teacher_name == 'b':
break else:
while True:
age = input('老师年方几何:')
if age.isdigit() and 0 < int(age) < 150:
break
else:
print('年龄必须为大于0,小于150的整数')
sex = input('请输入性别:').strip()
course = input('老师教什么:').strip()
salary = input('要多少工资:').strip()
passwd = input('请为您设置密码:').strip()
new_teacher_obj = Teacher(new_teacher_name,passwd,age,sex,course,salary,self.school_name)
self.school_teachers[new_teacher_name] = new_teacher_obj
school_info = self.readschooldb()
school_info[self.school_name] = self
self.writeschooldb(school_info)
print('老师:%s创建成功'% new_teacher_name) def create_grade(self):
'''管理员创建班级'''
while True:
grade_info = self.school_grades
if len(grade_info):
print('当前已经开设的班级如下:')
for grade_name in grade_info:
print(grade_name)
if len(self.school_course) == 0:
print('\033[31;1m当前学校未开设任何课程,请先创建课程,再创建班级\033[0m')
break
new_grade_name = input('请输入要创建的班级名称(b退回):').strip()
if new_grade_name in self.school_grades or new_grade_name == '':
print('\033[31;1m您要创建的班级已存在(或不合法),Please 重新输入\033[0m')
continue
elif new_grade_name == 'b':
break
# else:
while True:
print('当前本校已开设课程如下,请为班级选择课程:')
for course_name in self.school_course:
print(course_name)
chose_course = input('请选择>>>:').strip()
if chose_course in self.school_course:
break
else:
print('您输入的课程不存在,请重新输入:')
# else: if len(self.school_teachers ) == 0:
print('\033[31;1m当前学校未招聘任何老师,请先再创建班级\033[0m')
break
while True:
print('本校区已招聘老师名单如下:')
for teacher_name in self.school_teachers :
print(teacher_name)
chose_teacher = input('请为班级选择老师>>>:').strip()
if chose_teacher in self.school_teachers:
break
else:
print('\033[31;1m您输入的老师不存在\033[0m') grade_start_time = input('输入班级开课时间:').strip()
new_grade = Grade(new_grade_name, chose_course, chose_teacher, grade_start_time)
self.school_grades[new_grade_name] = new_grade
'''下面将新创建的班级添加到学校数据库中'''
school_info = self.readschooldb()
school_info[self.school_name] = self
self.writeschooldb(school_info)
print('\033[32;1m建班级:%s成功!\033[0m'% new_grade_name) def add_student(self):
'''管理员自主添加学员'''
while True:
grade_info = self.school_grades
if len(grade_info):
print('添加学员,请先选择班级,当前本校区已经开设的班级如下:')
for grade_name in grade_info:
print(grade_name)
chose_grade = input('\033[31;1m请输入要选择班级(b退出):\033[0m').strip()
if chose_grade in self.school_grades:
while True:
name = input('输入要添加的学员名字:').strip()
if name in self.school_grades[chose_grade].students or name == '':
print('\033[31;1m学员名字不合法,或班级内已存在,请重新输入...\033[0m')
else:
break
while True:
age = input('输入学员年龄:')
if age.isdigit() and 0 < int(age) < 150:
break
else:
print('年龄必须为大于0,小于150的整数')
sex = input('输入学员性别:').strip()
passwd = input('为学员设置密码:').strip()
'''创建学员'''
stu_obj = Student(name,passwd,age,sex,chose_grade,self.school_name)
'''存储到学校数据'''
self.school_grades[chose_grade].students[name] = stu_obj
self.school_students[name] = stu_obj
school_info = self.readschooldb()
school_info[self.school_name] = self
self.writeschooldb(school_info)
'''存储到班级数据中'''
grade_info = self.readgradedb()
grade_info[chose_grade].students[name] = stu_obj
self.writegradedb(grade_info)
print('\033[32;1m学员:%s注册成功!信息如下请牢记自己的密码\033[0m'% name)
stu_info = '''
姓名:%s
年龄:%s
性别:%s
班级:%s
应缴学费:%s
缴费状态:%s
所属校区:%s
课程成绩:%s
'''%(stu_obj.name,stu_obj.age,stu_obj.sex,stu_obj.stu_grade,stu_obj.tuition,stu_obj.payment_status,stu_obj.stu_school,stu_obj.score)
print(stu_info)
break
elif chose_grade == 'b':
break
else:
print('\033[31;1m您选择的班级不存在\033[0m')
else:
print('\033[31;1m当前学校未设置任何班级,请先添加班级后再添加学员\033[0m')
break

SchoolClass.py

#!/usr/bin/env python
# Author:Zhangmingda
from RWdb import RWdb class Course(RWdb):
'''定义一个课程有哪些属性&方法'''
def __init__(self,course_name,price,period):
self.course_naem = course_name
self.price = price
self.period = period
'''获取所有校区最新课程数据'''
course_info = self.readcoursedb()
'''添加刚刚创建的课程对象,到获取 最新课程数据中'''
course_info[self.course_naem] = self
'''将更新后的数据保存到文件中'''
self.writecoursedb(course_info)

CourseClass.py

#!/usr/bin/env python
# Author:Zhangmingda
from RWdb import RWdb
class Grade(RWdb):
'''定义一个班级的样子(属性:名字课程老师学生)'''
def __init__(self,name,course,teacher,start_time):
self.grade_name = name
self.course_name = course
self.teachers_name = []
self.teachers_name.append(teacher)
self.start_time = start_time
self.students = {}
'''将新创建的实例加入到已有实例字典中'''
grade_info = self.readgradedb()
grade_info[self.grade_name] = self
self.writegradedb(grade_info) teachers_info = self.readteachersdb()
teachers_info[teacher].teach_grade[self.grade_name] = self
self. writeteachersdb(teachers_info)

GradeClass.py

#!/usr/bin/env python
# Author:Zhangmingda
from RWdb import RWdb
from SchoolPeopleClass import People
class Teacher(People,RWdb):
'''定义一个老师该有的属性和方法'''
def __init__(self,name,passwd,age,sex,course,salary,school):
super(Teacher,self).__init__(name,passwd,age,sex)
self.teacher_course = course
self.teacher_salary = salary
self.teacher_school = school
self.teach_grade = {}
'''定义后就存储起来老师数据'''
teachers_info = self.readteachersdb()
teachers_info[self.name] = self
self. writeteachersdb(teachers_info)
def show_teach_grades(self):
print('\033[32;1m您所教班级如下:\033[0m')
for grade in self.teach_grade:
print(grade)
def show_grade_students(self):
while True:
self.show_teach_grades()
# print('查看所教班级学员列表'.center(40, '#'))
chose_grade = input('\033[31;1m请输入要查看的班级名称\033[0m').strip()
if chose_grade in self.teach_grade:
grade_obj = self.readgradedb()[chose_grade]
print('当前班级(%s)学员如下:'% chose_grade)
for student in grade_obj.students:
print(student)
break
else:
print('\033[31;1m您选择的班级不存在,请重新输入\033[0m') def teacher_info(self):
'''查看教师个人信息'''
teacher_info = '''
姓名:%s
年龄:%s
性别:%s
所教班级:%s
所教课程:%s
所在学校:%s
当前工资:%s'''%(self.name,self.age,self.sex,self.teach_grade.keys(),self.teacher_course,self.teacher_school,self.teacher_salary)
print('\033[33;1m:%s 你好,您的个人信息如下\033[0m'.center(50,'#')% self.name)
print(teacher_info)

TeacherClass.py

#!/usr/bin/env python
# Author:Zhangmingda
class People(object):
def __init__(self,name,passwd,age,sex):
self.name = name
self.passwd = passwd
self.age = age
self.sex = sex

SchoolPeopleClass.py

#!/usr/bin/env python
# Author:Zhangmingda
import os,sys
BASER_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__) ))
sys.path.append(BASER_DIR)
from core import main if __name__ == '__main__':
main.login_sys()

start.py

选课系统V1.0的更多相关文章

  1. 学生选课系统v1.0

    最近两天写了下老师课上留的作业:学生选课系统.感觉自己写的特别麻烦,思路特别不清晰,平常自己总会偷懒,一些太麻烦细节的功能就不去实现了,用简单的功能来替代,直到自己这回写完这个系统(但自己写的比较lo ...

  2. 新课程网上选课系统V1.0—适用于中小学校本课程选课、选修课选课

    学校要开设选修课,人工选课实施了两年,耗时耗力,于是打算用网上选课,在网上搜索了一番,没多少实用的,有一个网上用的比较多的,功能太简单了,于是打算自己开发一个,功能参考了部分学校的功能,也有基于Aja ...

  3. 码农很忙代理IP系统V1.0版本上线

    码农很忙代理IP系统V1.0版本上线 经过为期一个月的重写和测试,新版本的码农很忙代理IP系统已于今日正式上线.新版本拥有更精准的匿名类型识别和更高效的验证调度算法. 新版本仍旧采用ASP.NET B ...

  4. 地图标绘系统V1.0测试版【申明:来源于网络】

    地图标绘系统V1.0测试版[申明:来源于网络] 地址:http://blog.csdn.net/allgis/article/details/39718085

  5. 启明星手机版安卓android会议室预定系统 V1.0发布

    启明星手机版会议室预定系统 V1.0发布 在手机里输入 http://www.dotnetcms.org/e4.apk 或者扫描二维码下载 用户打开系统,可以实时查看所有会议室状态 点击会议室名称,可 ...

  6. ISkyShop B2B2C 商城系统V1.0正式版隆重公布

    ISkyShop核心开发团队结合7年电商开发经验,历经1年多时间的设计研发,于2014年6月12日隆重推出ISkyShop B2B2C 商城系统V1.0,B2B2C商城系统是ISkyShop独立自主研 ...

  7. “公文流转系统 v1.0”

    1.项目需求: 河北金力集团是我省机械加工的龙头企业,主要从事矿山机械制造及各种机械零部件加工.企业有3个厂区,主厂区位于省高新技术开发区,3个分厂分别在保定.邢台和唐山.为增加企业的核心竞争力和加强 ...

  8. 北京易信软科信息技术有限公司-仓库管理系统V1.0

    北京易信软科您可信赖的北京软件研发服务商,公司团队有多年应用软件设计制作及开发经验,为各大企业提供软件设计.制作及维护服务,为用户提供可靠高效的应用服务平台 我们通过专业的项目实施流程,为您提供优质的 ...

  9. 为了圣像画系统V1.0Beta版(javascript)-GIS520社区

    地图标绘系统V1.0測试版 (界面比較难看,之后再统一美化!)   演示地址:http://www.gis520.com/gis/plotdemo/index.html 查看可在菜单Map--> ...

随机推荐

  1. 明明pip安装python的模块了,pycharm还是找不到的解决方案

    以前pycharm的安装包和python的环境一直都不能融合在一起,到了今天才知道,原来他们都是有自己的工作环境的 自己的工作环境(虚拟解释器)和安装python的工作环境(基本解释器)不是一个环境, ...

  2. 2021年春秋杯网络安全联赛秋季赛 勇者山峰部分wp

    1.签到题-Crypto Vigenere 根据题目Vigenere可看出是维吉尼亚密码 使用在线网站破解 https://guballa.de/vigenere-solver flag:53d613 ...

  3. 【POJ1845】Sumdiv【算数基本定理 + 逆元】

    描述 Consider two natural numbers A and B. Let S be the sum of all natural divisors of A^B. Determine ...

  4. CF932F Escape Through Leaf

    CF932F Escape Through Leaf 首先, $ O(n^2) $ dp 是很显然的,方程长这样: \[dp[u] = min\{dp[v] + a_u\times b_v\} \] ...

  5. 数据仓库分层中的ODS、DWD、DWS

    1.数据仓库DW 1.1简介 Data warehouse(可简写为DW或者DWH)数据仓库,是在数据库已经大量存在的情况下,为了进一步挖掘数据资源.为了决策需要而产生的,它是一整套包括了etl.调度 ...

  6. 【机器学习与R语言】7-回归树和模型树

    目录 1.理解回归树和模型树 2.回归树和模型树应用示例 1)收集数据 2)探索和准备数据 3)训练数据 4)评估模型 5)提高模型性能 1.理解回归树和模型树 决策树用于数值预测: 回归树:基于到达 ...

  7. halt

    halt命令用来关闭正在运行的Linux操作系统.halt命令会先检测系统的runlevel,若runlevel为0或6,则关闭系统,否则即调用shutdown来关闭系统. 语法 halt(选项) 选 ...

  8. rust shadow

    1 fn main() { 2 let mut demo = 12; 3 println!("{}",demo); 4 demo = 21; // 值可变,数据类型不可变 5 pr ...

  9. C语言 序列反向互补函数

    1 static char *revers(char *s) 2 { 3 int len=strlen(s); 4 char *s2=(char *)malloc(sizeof(char)*(len+ ...

  10. Excel-返回列表或数据库中的分类汇总(汇总可以实现要还是不要统计隐藏行功能) subtotal()

    SUBTOTAL函数 函数名称:SUBTOTAL 主要功能:返回列表或数据库中的分类汇总. 使用格式:SUBTOTAL(function_num, ref1, ref2, ...) 参数说明:Func ...