python 实现学生信息管理系统 源代码
时间: 2023-11-14 08:07:15 浏览: 42
Sure, I can help you with that! Here's a sample Python code for a student information management system:
```
class Student:
def __init__(self, name, age, gender, grade):
self.name = name
self.age = age
self.gender = gender
self.grade = grade
class StudentManager:
def __init__(self):
self.students = []
def add_student(self, name, age, gender, grade):
student = Student(name, age, gender, grade)
self.students.append(student)
def display_students(self):
for student in self.students:
print(f"Name: {student.name}, Age: {student.age}, Gender: {student.gender}, Grade: {student.grade}")
# Let's add some students to test the system
manager = StudentManager()
manager.add_student("John", 18, "Male", "12th")
manager.add_student("Lisa", 17, "Female", "11th")
manager.add_student("Alex", 16, "Male", "10th")
# Display all the students
manager.display_students()
```
This code creates two classes - `Student` and `StudentManager`. The `Student` class holds information about a single student, while the `StudentManager` class manages a list of students. The `add_student` method adds new students to the list, and `display_students` method shows all the students in the list.
I hope this helps! If you have any more questions, feel free to ask.