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("输入有误请重新输入")
  • 相关阅读:
    【转】win7“您可能没有权限使用网络资源”的解决办法
    windows下顽固软件卸载不了的解决方法
    【转】Windows Server 2008修改远程桌面连接数
    winserver2008,运行可执行文件,提示 激活上下文生成失败。 找不到从属程序集 Microsoft.VC90.DebugCRT,processorArchitecture="x86"
    保障视频4G传输的流畅性,海康威视摄像头相关设置
    【转】win7如何设置共享目录,并且访问不需要输入用户名和密码。
    CentOS7.1配置远程桌面
    C++遍历目录,并把目录里超过7天的文件删除(跨平台windows&linux)
    hibernate(二)一级缓存和三种状态解析
    Android进程间的通信之AIDL
  • 原文地址:https://www.cnblogs.com/weisimin123/p/13889853.html
Copyright © 2011-2022 走看看