python写学生信息管理系统
时间: 2023-02-23 12:00:08 浏览: 65
您可以使用 Python 写一个学生信息管理系统。您可以创建一个学生类,其中包含学生的姓名、年龄、学号等信息,然后将多个学生对象存储在一个列表中,并可以使用一些函数来查询、添加和删除学生信息。
例如:
```
class Student:
def __init__(self, name, age, student_id):
self.name = name
self.age = age
self.student_id = student_id
students = []
def add_student(name, age, student_id):
students.append(Student(name, age, student_id))
def search_student(student_id):
for student in students:
if student.student_id == student_id:
return student
return None
def remove_student(student_id):
student = search_student(student_id)
if student:
students.remove(student)
add_student("张三", 20, "123456")
add_student("李四", 21, "234567")
add_student("王五", 22, "345678")
student = search_student("123456")
if student:
print("学生姓名:", student.name)
print("学生年龄:", student.age)
print("学生学号:", student.student_id)
remove_student("234567")
```
这是一个简单的学生信息管理系统代码框架,您可以根据需要进行扩展和完善。
相关推荐
![7z](https://img-home.csdnimg.cn/images/20210720083312.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)