stuName = ['白柳', '牧四城', '刘佳仪'] # stu
stuId = ['006', '004', '061'] # sid
stuClass = ['A003', 'A003', 'A001'] # clas
def showMune():
print("""1.添加学生信息
2.删除学生信息
3.修改学生信息
4.查询所有学生信息
0.退出系统""")
print("=========")
def add():
global stuName
global stuId
global stuClass
stu = input("请输入学生姓名(输入exit退出):")
while stu != 'exit':
for i in range(0, len(stuName)):
while stu == stuName[i]:
stu = input("学生姓名重复,请重新输入")
if stu == 'exit':
main()
stuName.append(stu)
sid = input("请输入学生id:")
for i in range(0, len(stuId)):
while sid == stuId[i]:
sid = input("学生id重复,请重新输入")
stuId.append(sid)
clas = input("请输入学生班级:")
stuClass.append(clas)
stu = input("请输入学生姓名(输入exit退出):")
def delt_(i): #删除操作
stuName.remove(stuName[i])
stuId.remove(stuId[i])
stuClass.remove(stuClass[i])
def delt():
global stuName
global stuId
global stuClass
x = int(input("请输入删除方式:(1.姓名 2.id 3.退出)"))
while x != 3:
i=0
if x == 1:
restu = input("请输入你要删除的学生姓名")
for i in range(0, len(stuName)):
if restu == stuName[i]:
break
if i + 1 == len(stuId):
print("学生不存在,请重新输入")
return delt()
elif x == 2:
restu = input("请输入你要删除的学生id")
for i in range(0, len(stuId)):
if restu == stuId[i]:
break
if i + 1 == len(stuId):
print("学生不存在,请重新输入")
return delt()
delt_(i)
x = int(input("请输入删除方式:(1.姓名 2.id 3.退出)"))
def re_(i): #修改操作
global stuName
global stuId
global stuClass
redata = input("请输入修改后学生姓名:")
j=0
for j in range(0, len(stuName)):
while redata == stuName[j]:
redata = input("学生姓名重复,请重新输入")
stuName[i] = redata
redata = input("请输入修改后学生id:")
for j in range(0, len(stuId)):
while redata == stuId[j]:
redata = input("学生id重复,请重新输入")
stuId[i] = redata
stuClass[i] = input("请输入修改后学生班级:")
def re():
global stuName
global stuId
global stuClass
x = int(input("请输入修改方式:(1.姓名 2.id 3.退出)"))
while x != 3:
i=0
if x == 1:
restu = input("请输入你要修改的学生姓名")
for i in range(0, len(stuName)):
if restu == stuName[i]:
re_(i)
break
if i + 1 == len(stuName):
print("学生不存在,请重新输入")
return re()
elif x == 2:
restu = input("请输入你要修改的学生id")
for i in range(0, len(stuId)):
if restu == stuId[i]:
re_(i)
break
if i + 1 == len(stuId):
print("学生不存在,请重新输入")
return re()
x = int(input("请输入修改方式:(1.姓名 2.id 3.退出)"))
def show():
global stuName
global stuId
global stuClass
print("学生姓名 学生id 学生班级")
for i in range(0, len(stuName)):
print('{0:10s}{1:10s}{2:10s}'.format(stuName[i], stuId[i], stuClass[i]))
def choose(o):
if o == 1:
print(1)
add()
elif o == 2:
print(2)
delt()
elif o == 3:
print(3)
re()
elif o == 4:
print(4)
show()
def main():
print("=========\n学生管理系统V10.0")
showMune()
o = int(input("请输入你的操作:"))
while o:
if o != 0:
choose(o)
showMune()
o = int(input("请输入你的操作:"))
else:
break
main()