python入门(1)__学生信息管理系统

要实现的功能:添加、查看、修改学生信息。

要存储的数据:学生信息(学号、姓名、性别),管理者信息(账号、密码)

Tips:

1、以字典为单位存储信息。

2、定义不同的函数,实现对不同功能模块的封装。

3、使用条件函数进行功能间的跳转。

注意:写程序的顺序和功能调用的顺序是相反的。

user=[]
students=[]

def all_look():
    for i in students:
        print(i)
    choice=int(input('1.返回学生信息管理页面。2.返回主菜单'))
    if choice==1:
        student()
    elif choice==2:
        manage()
    else:
        print('worry')

def student_add():
    print('【添加学生信息】')
    su=input('学号')
    sname=input('姓名')
    sr=input('性别')
    s={'id':su,'name':sname,'sex':sr}
    if s not in students:
        students.append(s)
        print('添加成功')
    else:
        print('请勿重复添加!')
    choice=int(input('1.返回学生信息管理页面。2.返回主菜单'))
    if choice==1:
        student()
    elif choice==2:
        manage()
    else:
        print('worry')
        
def student_write():
    ops=input('请输入要修改的学号:')
    for i in students:
        if i['id']==ops:
            aa=i['id']
            bb=i['name']
            cc=i['sex']
            print(f'学号:{aa} 姓名:{bb},性别:{cc}')
            xname=input('修改后的姓名:')
            xsex=input('修改后的性别:')
            c_=int(input('请确认要进行的操作:1.修改。2.删除。'))
            if c_==1:
                i['name']=xname
                i['sex']=xsex
                print('修改成功')
            elif c_==2:
                i[id]='delete'
                print('删除成功')
            else:
                print('worry')
        break
    choice=int(input('1.返回学生信息管理页面。2.返回主菜单'))
    if choice==1:
        student()
    elif choice==2:
        manage()
    else:
        print('worry')
        
def student_look():
    lookid=input('请输入学号进行查询:')
    for i in students:
        if i['id']==lookid:
            aa=i['id']
            bb=i['name']
            cc=i['sex']
            print(f'学号:{aa} 姓名:{bb},性别:{cc}')
            break
    choice=int(input('1.返回学生信息管理页面。2.返回主菜单'))
    if choice==1:
        student()
    elif choice==2:
        manage()
    else:
        print('worry')
        
def student():
    print('【学生信息管理页面——请选择功能】')
    s11=int(input('1.查看学生信息。2.添加学生信息。3.编辑学生信息.4.查看全部学生信息 5.返回主菜单'))
    if s11==1:
        student_look()
    elif s11==2:
        student_add()
    elif s11==3:
        student_write()
    elif s11==4:
        all_look()
    elif s11==5:
        manage()
    else:
        print('worry')
        
def manage():
    print('【主菜单——请选择功能】')
    s1=int(input('1. 进入学生信息管理页面。2.返回登陆界面。'))
    if s1==1:
        student()
    if s1==2:
        login()
    else:
        print('worry')
        
def login():
    print('【登录】')
    l_id=input('请输入账号:')
    l_password=input('请输入密码:')
    l={'id':l_id,'password':l_password}
    if l in user:
        print('登陆成功')
        manage()
    else:
        print('该用户未注册,请注册后登陆!')
        adduser()
        
def adduser():
    print('【注册】')
    u_id=input('请输入账号:')
    u_password=input('请输入密码:')
    u={'id':u_id,'password':u_password}
    if u in user:
        print('用户已注册,请直接登陆!')
    else:
        user.append(u)
        print('注册成功,请登陆!')
    login()


a=int(input('1.登陆 2.注册'))
if a==2:
    adduser()
elif a==1:1
    login()
else:
    print('worry')

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值