Fundamentals 11 min read

Python Student Information Management System Tutorial

This tutorial presents a complete Python console program for managing student records, explaining its features, step‑by‑step implementation of add, delete, modify, search, and display functions, and providing full source code with example usage screenshots.

Python Programming Learning Circle
Python Programming Learning Circle
Python Programming Learning Circle
Python Student Information Management System Tutorial

This article introduces a simple Python console application for managing student information, outlining its features such as adding, deleting, modifying, searching, and displaying student records.

It first describes the system overview and step‑by‑step analysis, then details the implementation of each function (info_print, add_info, del_info, modify_info, search_info, print_all) with corresponding code snippets.

Sample interaction screenshots illustrate adding and deleting students, modifying and searching records, and displaying all students before exiting the system.

Finally, the complete source code of the program is provided, serving as a learning example for basic CRUD operations in Python.

<code># 定义一个函数</code>
<code>def info_print():</code>
<code>    print('--------请选择功能-----')</code>
<code>    print('1、添加学生')</code>
<code>    print('2、删除学生')</code>
<code>    print('3、修改学生')</code>
<code>    print('4、查询学生')</code>
<code>    print('5、显示所有学生')</code>
<code>    print('6、退出系统')</code>
<code>    print('-' * 20)</code>
<code></code>
<code># 等待存储所有学生的信息</code>
<code>info = []</code>
<code></code>
<code># 1、添加学生信息的函数</code>
<code>def add_info():</code>
<code>    """添加学生函数"""</code>
<code>    new_id = input("输入学号:")</code>
<code>    new_name = input("输入姓名:")</code>
<code>    new_tel = input("输入手机号:")</code>
<code>    global info</code>
<code>    for i in info:</code>
<code>        if new_name == i['name']:</code>
<code>            print("此用户已经存在,请勿重复添加")</code>
<code>            return</code>
<code>    info_dict = {'id': new_id, 'name': new_name, 'tel': new_tel}</code>
<code>    info.append(info_dict)</code>
<code>    print(info)</code>
<code></code>
<code># 2、删除学生的信息</code>
<code>def del_info():</code>
<code>    """删除学生"""</code>
<code>    del_name = input("请输入要删除的学生的姓名:")</code>
<code>    global info</code>
<code>    for i in info:</code>
<code>        if del_name == i['name']:</code>
<code>            info.remove(i)</code>
<code>            break</code>
<code>    else:</code>
<code>        print('该学生不存在!')</code>
<code>    print(info)</code>
<code></code>
<code># 3、修改学生的信息</code>
<code>def modify_info():</code>
<code>    """修改函数"""</code>
<code>    modify_name = input("请输入要修改的学生的姓名:")</code>
<code>    global info</code>
<code>    for i in info:</code>
<code>        if modify_name == i['name']:</code>
<code>            i['tel'] = input("请输入新的手机号:")</code>
<code>            break</code>
<code>    else:</code>
<code>        print("该学生不存在")</code>
<code>    print(info)</code>
<code></code>
<code># 4、查询学生信息</code>
<code>def search_info():</code>
<code>    """查询学生信息"""</code>
<code>    search_name = input("请输入要查找的学生姓名:")</code>
<code>    global info</code>
<code>    for i in info:</code>
<code>        if search_name == i['name']:</code>
<code>            print("找到该学生的信息如下:")</code>
<code>            print(f"该学生的学号是{i['id']},姓名是{i['name']},手机号是{i['tel']}")</code>
<code>            break</code>
<code>    else:</code>
<code>        print("该学生不存在!")</code>
<code></code>
<code># 5、显示所有学生信息</code>
<code>def print_all():</code>
<code>    """显示所有学生信息"""</code>
<code>    print('学号\t姓名\t手机号')</code>
<code>    for i in info:</code>
<code>        print(f"{i['id']}\t{i['name']}\t{i['tel']}")</code>
<code></code>
<code># 系统功能需要循环使用,直到用户输入6,才退出系统</code>
<code>while True:</code>
<code>    info_print()</code>
<code>    user_num = eval(input('请输入功能序号:'))</code>
<code>    if user_num == 1:</code>
<code>        add_info()</code>
<code>    elif user_num == 2:</code>
<code>        del_info()</code>
<code>    elif user_num == 3:</code>
<code>        modify_info()</code>
<code>    elif user_num == 4:</code>
<code>        search_info()</code>
<code>    elif user_num == 5:</code>
<code>        print_all()</code>
<code>    elif user_num == 6:</code>
<code>        exit_flag = input("确定要退出吗?yes/no?")</code>
<code>        if exit_flag == 'yes':</code>
<code>            break</code>
<code>    else:</code>
<code>        print('输入的功能序号有误!')</code>
CRUDstudent-managementConsole Application
Python Programming Learning Circle
Written by

Python Programming Learning Circle

A global community of Chinese Python developers offering technical articles, columns, original video tutorials, and problem sets. Topics include web full‑stack development, web scraping, data analysis, natural language processing, image processing, machine learning, automated testing, DevOps automation, and big data.

0 followers
Reader feedback

How this landed with the community

login Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.