Project actual combat-create a student information management system

Project goal:
complete an online student information management system

  • The data is temporarily stored in the variable list
  • Realize the operation of adding, deleting and querying student information

Through actual cases, exercise and consolidate the basic knowledge of Python
as shown in the figure below: Student information management system interface
1. Initial interface
Insert picture description here2. Add student information
Insert picture description here3. After adding student information , you need to view student information
Insert picture description here
4. Delete specified student information
Insert picture description here
5. Exit student information management After the system
Insert picture description here
gets a project, first establish an analysis idea:

  1. First analyze what functions of the project need to be implemented
  2. What are the core functions of the project
  3. What is the interface display
  4. How the interface interacts with the user
'''
1.学员信息数据源
2.实现的功能:
    1查看学员信息
    2添加学员信息
    3删除学员信息
    4退出系统
3.界面交互
'''
# 1.学员信息数据源
stu_list=[
    {
    
    'name':'zhangsan','age':20,'classid':'python01'},
    {
    
    'name':'lisi','age':28,'classid':'python02'},
    {
    
    'name':'wangwu','age':21,'classid':'python03'}]
# 2.1实现功能-查看学员信息

def show_stus_info():
    '''

    :return:
    '''
    if len(stu_list)==0:
        print('='*20,'没有学员信息','='*20)
        return
    print('|{0:<5}|{1:<10}|{2:<5}|{3:<10}|'.format('sid','name','age','classid'))
    print('-'*40)
    for i,stu_dict in enumerate(stu_list):
        print('|{0:<5}|{1:<10}|{2:<5}|{3:<10}|'.format(i+1,stu_dict['name'],stu_dict['age'],stu_dict['classid']))
# 测试2.1 查看学员信息
#show_stus_info()

# 2.2实现功能-添加学员信息
def add_stu(name,age,classid):
    stu_dict={
    
    }
    stu_dict['name']=name
    stu_dict['age']=age
    stu_dict['classid']=classid
    stu_list.append(stu_dict)
# 测试2.2添加学员信息

add_stu('yh',13,'python04')
# show_stus_info()

# 2.3 删除学员信息
def del_stu(sid):
    sid_int=int(sid)
    stu_list.pop(sid_int-1)
# 2.3 删除学员信息
# del_stu(3)
# show_stus_info()

# 2.4 退出系统
def loginOut():
    pass
# 界面交互

while True:
    # 输出初始界面
    print('='*12,'学员管理系统','='*12)
    print('{:1} {:13} {:15}'.format('','1.查看学员信息','2.添加学员信息'))
    print('{:1} {:13} {:15}'.format('', '3.删除学员信息', '4.退出系统'))
    print('='*40)
    key=input('请输入对应的选择')
    # 根据输入值,执行对应操作
    if key=='1':
        print('='*12,'学员信息浏览','='*12)
        show_stus_info()
        input('按回车继续:')
    elif key=='2':
        print('='*12,'添加学员信息','='*12)
        name=input('请输入姓名:')
        age = input('请输入年龄:')
        classid = input('请输入班级号:')
        add_stu(name,age,classid)
        show_stus_info()
        input('按回车继续:')
    elif key=='3':
        print('=' * 12, '删除学员信息', '=' * 12)
        show_stus_info()
        sid=input('请你输入要删除的学员的sid')
        del_stu()
        show_stus_info()
        input('按回车继续:')
    elif key=='4':
        loginOut()
        print('=' * 12, '再见', '=' * 12)
        break
    else:
        print('=' * 12, '无效操作', '=' * 12)

Realization effect display:

D:\python3.8.6\python.exe D:/爬虫/pythonProject/实战/学员信息管理系统.py
============ 学员管理系统 ============
  1.查看学员信息      2.添加学员信息       
  3.删除学员信息      4.退出系统         
========================================
请输入对应的选择1
============ 学员信息浏览 ============
|sid  |name      |age  |classid   |
----------------------------------------
|1    |zhangsan  |20   |python01  |
|2    |lisi      |28   |python02  |
|3    |wangwu    |21   |python03  |
|4    |yh        |13   |python04  |
按回车继续:2
============ 学员管理系统 ============
  1.查看学员信息      2.添加学员信息       
  3.删除学员信息      4.退出系统         
========================================
请输入对应的选择2
============ 添加学员信息 ============
请输入姓名:yh2
请输入年龄:23
请输入班级号:iii
|sid  |name      |age  |classid   |
----------------------------------------
|1    |zhangsan  |20   |python01  |
|2    |lisi      |28   |python02  |
|3    |wangwu    |21   |python03  |
|4    |yh        |13   |python04  |
|5    |yh2       |23   |iii       |
按回车继续:
============ 学员管理系统 ============
  1.查看学员信息      2.添加学员信息       
  3.删除学员信息      4.退出系统         
========================================
请输入对应的选择4
============ 再见 ============

Process finished with exit code 0

Project actual combat summary:

  • Information input and output
  • Use of common data types
  • Branch structure
  • Cyclic structure
  • Function definition and use

The project implementation process is relatively simple. As a beginner, practice how to understand how computers deal with problems. In fact, the most important thing is the transformation of thinking. You need to transform real business problems into computer-understandable codes through your analysis and help you realize them.

Guess you like

Origin blog.csdn.net/weixin_42961082/article/details/111876152