2020-11-12

‘’’
学生管理系统
实现增删改查操作
‘’’

#定义一个功能菜单
def function_menu():
print("-" *30)
print(“学生信息管理系统”)
print(“1.添加学生信息”)
print(“2.删除学生信息”)
print(“3.修改学生信息”)
print(“4.显示所有学生信息”)
print(“0.退出系统”)
print("-" *30)

def information_add():
name=input(“请输入要添加的学生姓名:”)
sex=input(“请选择该学生的性别:男/女”)
Phone=input(“请输入该学生的手机号码:”)
studentinformation={}
studentinformation[‘name’]=name
studentinformation[‘sex’]=sex
studentinformation[‘Phone’]=Phone
student_information.append(studentinformation)

def information_del():
number=int(input(“请输入要删除的学生序号:”))-1
del student_information[number]

def information_chg():
number=int(input(“请输入要修改的学生序号:”))
new_name=input(“请输入修改后的学生姓名:”)
new_sex=input(“请输入修改后的学生性别:”)
new_Phone=input(“请输入修改后的学生电话号码:”)
student_information[number-1][‘name’]=new_name
student_information[number-1][‘sex’]=new_sex
student_information[number-1][‘Phone’]=new_Phone

def information_show():
print("*" 30)
print(“学生信息如下:”)
print("
" *30)
print(“序号 姓名 性别 电话号码”)
i=1
for temp in student_information:
print("%d %s %s %s"% (i,temp[‘name’],temp[‘sex’],temp[‘Phone’]))
i+=1

def main():
while True:
function_menu()
key=int(input(“请输入功能对应的序号:”))
if key == 1 :
information_add()
elif key == 2 :
information_del()
elif key == 3 :
information_chg()
elif key == 4 :
information_show()
elif key == 0 :
last_func=input(“退出?Yes/No”)
if last_func==“Yes”:
break
else:
print(“输入有误,请重新输入!!!”)

#测试一下是否可行
main()

评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值