学生姓名,学号,专业,班级 学生所在宿舍,各宿舍卫生评比情况 宿舍费用管理,遗失信息管理 人员请假情况,人员违纪情况 报修情况管理,门禁信息管理 Python做代码
时间: 2024-03-16 09:45:18 浏览: 47
Python实现学生管理系统,可以对学生信息进行添加、删除、修改、查询、排序、统计
以下是一个简单的 Python 代码示例,用于管理学生宿舍信息、卫生评比、费用、遗失、请假、违纪、报修和门禁信息。这只是一个示例,您可以根据实际需求进行修改和扩展。
```python
# 定义学生类
class Student:
def __init__(self, name, id, major, class_name, dormitory):
self.name = name
self.id = id
self.major = major
self.class_name = class_name
self.dormitory = dormitory
self.lease = None # 宿舍费用
self.lost = [] # 遗失物品
self.leave = [] # 请假记录
self.violation = [] # 违纪记录
self.repair = [] # 报修记录
self.access = [] # 门禁记录
def add_lease(self, amount):
self.lease = amount
def add_lost(self, item):
self.lost.append(item)
def add_leave(self, leave):
self.leave.append(leave)
def add_violation(self, violation):
self.violation.append(violation)
def add_repair(self, repair):
self.repair.append(repair)
def add_access(self, access):
self.access.append(access)
# 定义学生管理类
class StudentManager:
def __init__(self):
self.students = []
def add_student(self, student):
self.students.append(student)
def get_student_by_id(self, id):
for student in self.students:
if student.id == id:
return student
return None
# 示例代码
if __name__ == '__main__':
# 创建学生管理器
manager = StudentManager()
# 添加学生
student1 = Student("张三", "1001", "计算机科学与技术", "1班", "A栋501")
student1.add_lease(1000)
student1.add_lost("钱包")
student1.add_leave("2021-09-01")
student1.add_violation("2021-09-05", "未按时归寝")
student1.add_repair("2021-09-10", "水龙头坏了")
student1.add_access("2021-09-15", "进入宿舍楼")
student2 = Student("李四", "1002", "软件工程", "2班", "B栋601")
student2.add_lease(800)
student2.add_lost("手机")
student2.add_leave("2021-09-02")
student2.add_violation("2021-09-07", "吸烟")
student2.add_repair("2021-09-11", "电灯不亮")
student2.add_access("2021-09-16", "离开宿舍楼")
manager.add_student(student1)
manager.add_student(student2)
# 根据学号查找学生
student = manager.get_student_by_id("1001")
if student:
print(student.name)
print(student.lease)
print(student.lost)
print(student.leave)
print(student.violation)
print(student.repair)
print(student.access)
else:
print("未找到该学生")
```
在实际应用中,您需要根据实际需求对代码进行修改和扩展,例如添加更多的属性和方法,或者将数据存储到数据库中等。
阅读全文