studnetList = []
class Student:
sid = None
name = None
sex = None
number = None
b = True
num = 0
def addStudent(list,student):
student.sid = len(list) + 1
list.append(student)
print('添加成功!!!')
def deleteStudent(list,delid):
list.remove(delid - 1)
print('删除成功!!!')
def updateStudnet(list,student):
list[int(student.sid) - 1] = student
print('修改成功!!!')
def selectStudent(list):
print('============================================================================\n'
'序号\t\t\t\t\t\t姓名\t\t\t\t\t\t性别\t\t\t\t\t\t手机号码')
for s in list:
print(str(s.sid) + '\t\t\t\t\t\t' + str(s.name) + '\t\t\t\t\t\t' + s.sex + '\t\t\t\t\t\t' + s.number)
print('============================================================================\n')
while(b):
print('============================================================================\n'
'\t\t学生管理系统V1.0\n'
'\t\t1.添加学生信息\n'
'\t\t2.删除学生信息\n'
'\t\t3.修改学生信息\n'
'\t\t4.显示所有学生信息\n'
'\t\t0.退出系统\n'
'============================================================================\n')
num = int(input('请输入功能对应的数字:'))
if num == 0:
b = False
elif num == 1: #添加学生信息
student = Student()
student.name = input('请输入新同学的名字:')
student.sex = input('请输入新同学的性别(男/女):')
student.number = input('请输入新同学的手机号码:')
addStudent(studnetList,student)
elif num == 2: #删除学生信息
delid = int(input('请输入要删除的学生序号:'))
deleteStudent(studnetList,delid)
elif num == 3: #修改学生信息
student = Student()
student.sid = input('请输入要修改的同学序号:')
student.name = input('请输入要修改同学的名字:')
student.sex = input('请输入要修改同学的性别(男/女):')
student.number = input('请输入要修改同学的手机号码:')
updateStudnet(studnetList,student)
elif num == 4: #显示所有学生信息
selectStudent(studnetList)
print("欢迎下次使用!!!")
|