Update 学生管理.py

master
hnu202109060103 2 years ago
parent 3315684fad
commit 1c2fe274fb

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
"""
Created on Mon Dec 5 08:36:06 2022
@ -23,11 +22,10 @@ def print_message(*message):
# 读取stu.csv文件
def read_stu_csv():
stus = pd.read_csv("stu.csv",index_col= False)
stus = pd.read_csv("stu.csv", index_col= False)
return stus
# 查询全部学生信息
# 查询全部学生信息
def read_all_stus():
stus = read_stu_csv()
@ -77,8 +75,9 @@ def read_someone_by_phone():
break
read_someone_by_phone()
# 通过姓名/电话查询某个学生信息
# 通过姓名/电话查询某个学生信息
def read_stu():
stus = read_stu_csv()
stu_names = stus['姓名'].values.tolist()
@ -159,7 +158,7 @@ def update_by_name():
display(stus)
stu_names = stus['姓名'].values.tolist()
while True:
stu_name = input("请输入待添加学生姓名")
stu_name = input("请输入待修改学生姓名")
if stu_name not in stu_names:
print_message("学生不存在,请重新输入!")
continue
@ -206,6 +205,10 @@ def update_by_name():
continue
break
update_by_name()
# 通过电话修改某个学生电话
def update_by_phone():
@ -213,7 +216,7 @@ def update_by_phone():
display(stus)
stu_phones = stus['电话'].values.tolist()
while True:
stu_phone = input("请输入待添加学生电话")
stu_phone = input("请输入待修改学生电话")
if int(stu_phone) not in stu_phones:
print_message("学生不存在,请重新输入!")
continue
@ -262,6 +265,8 @@ def update_by_phone():
update_by_phone()
# 更改学生信息
def update_stu():
@ -311,3 +316,5 @@ def update_stu():
#
update_stu()

Loading…
Cancel
Save