zoukankan      html  css  js  c++  java
  • 学生管理系统

    """
    学生管理系统
    1.添加学生信息
    2.删除学生信息
    3.修改学生信息
    4.查找学生信息
    5.退出系统
    """
    import time
    
    
    def print_info():
        print("=" * 30)
        print("欢迎使用学生管理系统")
        print("1. 添加学生信息")
        print("2. 修改学生信息")
        print("3. 删除学生信息")
        print("4. 查询学生信息")
        print("5. 退出系统")
        print("=" * 30)
    
    
    def add_student():  # 添加学生信息
        global student_info  # 声明函数中要修改的是全局变量student_info
        dict_1 = {}
        name = input("请输入学生的姓名:")
        age = input("请输入学生的年龄:")
        sex = input("请输入学生的性别:")
        id = input("请输入学生的身份证号码:")
        dict_1["name"] = name  # 通过key添加value
        dict_1["age"] = age
        dict_1["sex"] = sex
        dict_1["id"] = id
        student_infor.append(dict_1)  # 将字典追加到列表的一个元素
    
    
    # student_infor = [{'name': 'zhangsna ', 'age': '20', 'sex': 'nv', 'id': '123456y'}]
    
    
    def alter_student():
        alter = int(input("请输入要修改的学生序号"))
        global student_infor
        name = input("请输入新的学生的姓名:(回车不修改)")
        if len(name) > 0:
            student_infor[alter - 1]["name"] = name
        age = input("请输入新的年龄,(回车不修改)")
        if len(age) > 0:
            student_infor[alter - 1]["age"] = age
        id = input("请输入新的id,(回车不修改)")
        if len(id) > 0:
            student_infor[alter - 1]["id"] = id
        sex = input("请输入新的性别,(回车不修改)")
        if len(sex) > 0:
            student_infor[alter - 1]["sex"] = sex
    
    
    def opp_student():
        opp_num = int(input("请输入要删除的学生序号:"))
        global student_infor
        del student_infor[opp_num - 1]
    
    
    def show_student():  # 显示学生信息
        show_num = int(input("请输入您要查询的学生信息:(0代表嘻查询所有的学生信息)"))
        if show_num != 0:
            for i, j in student_infor[show_num - 1].items():
                print(i, j)
        elif show_num == 0:
            m = 1
            for temp in student_infor:  # 遍历列表
                for x, y in temp.items():
                    print(m, x, y)
                    m += 1
            time.sleep(2)
    
    
    student_infor = []
    
    
    while True:
        print_info()
        choise = int(input('请输入您要选择的操作:(1~5)'))
        if choise in [1, 2, 3, 4, 5]:
            print("您选择的操作是", choise)
            if choise == 5:
                print("感谢使用该程序")
                num_1 = input("您确定要退出程序吗:(Y/N)")
                if num_1 == "Y":
                    break
                elif num_1 == "N":
                    continue
            elif choise == 1:
                print("您选择的操作是1")
                add_student()
                print(student_infor)
            elif choise == 2:
                print("您选择的操作是修改学生信息")
                alter_student()
                print(student_infor)
            elif choise == 3:
                print("您选择的操作是删除学生信息")
                opp_student()
            elif choise == 4:
                print("您选择的操做是查看学生信息")
                show_student()
                print(student_infor)
        else:
            print("输入有误请重新输入")
  • 相关阅读:
    理解HTTP的POST和PUT的区别
    眼见为实 — CSS的overflow属性
    Iconfont的代码使用
    JSP中contentType、pageEncoding和meta charset的区别
    在 webpack 中使用 ECharts
    MVC 中的 ViewModel
    一个简单例子理解C#的协变和逆变
    C#中使用委托、接口、匿名方法、泛型委托实现加减乘除算法
    c#打包文件解压缩
    8种主要排序算法的C#实现 (二)
  • 原文地址:https://www.cnblogs.com/weisimin123/p/13889853.html
Copyright © 2011-2022 走看看