|
|
|
@ -38,7 +38,7 @@ read_all_stus()
|
|
|
|
|
def read_someone_by_name():
|
|
|
|
|
stus = read_stu_csv()
|
|
|
|
|
display(stus)
|
|
|
|
|
stu_names = stus['姓名'].values.tolist()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
while True:
|
|
|
|
|
print_message("请输入查询学生姓名:")
|
|
|
|
@ -47,12 +47,11 @@ def read_someone_by_name():
|
|
|
|
|
print_message("学生不存在,请重新输入!")
|
|
|
|
|
continue
|
|
|
|
|
else:
|
|
|
|
|
stu = stus.loc[(stus['姓名'] == stu_name),:]
|
|
|
|
|
stu = stus.loc[(stus['姓名'] == stu_name)]
|
|
|
|
|
print_message("【{}】学生信息查询成功!".format(stu_name))
|
|
|
|
|
display(stu)
|
|
|
|
|
break
|
|
|
|
|
|
|
|
|
|
read_someone_by_name()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# 通过电话查询某个学生信息
|
|
|
|
@ -74,8 +73,6 @@ def read_someone_by_phone():
|
|
|
|
|
display(stu)
|
|
|
|
|
break
|
|
|
|
|
|
|
|
|
|
read_someone_by_phone()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# 通过姓名/电话查询某个学生信息
|
|
|
|
|
def read_stu():
|
|
|
|
@ -95,7 +92,7 @@ def read_stu():
|
|
|
|
|
else:
|
|
|
|
|
print_message("未查询到【{}】信息,请重新输入".format(stu_input))
|
|
|
|
|
continue
|
|
|
|
|
read_stu()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# 增加某个学生信息
|
|
|
|
|
def add_stu():
|
|
|
|
@ -150,7 +147,6 @@ def add_stu():
|
|
|
|
|
display(stu_df)
|
|
|
|
|
break
|
|
|
|
|
|
|
|
|
|
add_stu()
|
|
|
|
|
|
|
|
|
|
#通过姓名修改某个学生姓名
|
|
|
|
|
def update_by_name():
|
|
|
|
@ -206,7 +202,7 @@ def update_by_name():
|
|
|
|
|
break
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
update_by_name()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# 通过电话修改某个学生电话
|
|
|
|
@ -264,7 +260,7 @@ def update_by_phone():
|
|
|
|
|
break
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
update_by_phone()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# 更改学生信息
|
|
|
|
@ -314,7 +310,61 @@ def update_stu():
|
|
|
|
|
display(stus)
|
|
|
|
|
break
|
|
|
|
|
#
|
|
|
|
|
def del_stu():
|
|
|
|
|
stus = read_stu_csv()
|
|
|
|
|
stu_names = stus['姓名'].values.tolist()
|
|
|
|
|
stu_phones = stus['电话'].values.tolist()
|
|
|
|
|
while True:
|
|
|
|
|
stu_input = input("请输入学生姓名/电话:")
|
|
|
|
|
if stu_input in stu_names:
|
|
|
|
|
print_message("您确定删除此学生吗?")
|
|
|
|
|
confirm_flag = input("y/n:")
|
|
|
|
|
if confirm_flag == 'y':
|
|
|
|
|
x=stus[stus['姓名']==stu_input].index.tolist()[0]
|
|
|
|
|
|
|
|
|
|
stus.drop(x,axis=0,inplace=True)
|
|
|
|
|
|
|
|
|
|
print('删除成功')
|
|
|
|
|
stus.to_csv("stu.csv", index = True)
|
|
|
|
|
else :
|
|
|
|
|
print('终止操作')
|
|
|
|
|
display(stus)
|
|
|
|
|
|
|
|
|
|
break
|
|
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
print('重新输入姓名')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
print('你想查询的内容')
|
|
|
|
|
print('1.通过姓名查找学生信息')
|
|
|
|
|
print('2.通过电话查找学生信息')
|
|
|
|
|
print('3.通过姓名/电话查找学生信息')
|
|
|
|
|
print('4.通过姓名修改学生信息')
|
|
|
|
|
print('4.通过电话修改学生信息')
|
|
|
|
|
print('6.添加学生信息')
|
|
|
|
|
print('7.更新学生信息')
|
|
|
|
|
print('8.删除学生信息')
|
|
|
|
|
x=eval(input('请输入:'))
|
|
|
|
|
if x==1:
|
|
|
|
|
|
|
|
|
|
read_someone_by_name()
|
|
|
|
|
elif x==2:
|
|
|
|
|
read_someone_by_phone()
|
|
|
|
|
elif x==3:
|
|
|
|
|
read_stu()
|
|
|
|
|
elif x==4:
|
|
|
|
|
update_by_name()
|
|
|
|
|
elif x==5:
|
|
|
|
|
update_by_phone()
|
|
|
|
|
elif x==6:
|
|
|
|
|
add_stu()
|
|
|
|
|
elif x==7:
|
|
|
|
|
update_stu()
|
|
|
|
|
|
|
|
|
|
elif x==8:
|
|
|
|
|
del_stu()
|
|
|
|
|
else:
|
|
|
|
|
print('输入错误,重新输入')
|
|
|
|
|
|
|
|
|
|