parent
10d2434755
commit
f925106b2d
@ -0,0 +1,84 @@
|
|||||||
|
import requests
|
||||||
|
import bs4
|
||||||
|
|
||||||
|
class_info =[]
|
||||||
|
def add():
|
||||||
|
global class_info
|
||||||
|
name=input("请输入你的姓名: ")
|
||||||
|
sex=input("请输入你的性别: ")
|
||||||
|
number=int(input("请输入你的电话: "))
|
||||||
|
student ={
|
||||||
|
"姓名":name,
|
||||||
|
"性别": sex,
|
||||||
|
"电话": number
|
||||||
|
}
|
||||||
|
class_info.append(student)
|
||||||
|
return None
|
||||||
|
|
||||||
|
def dell():
|
||||||
|
name=input("输入删除学生姓名:")
|
||||||
|
for student in class_info:
|
||||||
|
if student["name"]==name:
|
||||||
|
class_info.remove(student)
|
||||||
|
return 0
|
||||||
|
|
||||||
|
def modify():
|
||||||
|
name = input("请输入需要修改的学生姓名:")
|
||||||
|
for student in class_info:
|
||||||
|
if student["name"] == name:
|
||||||
|
student["name"] = input("请输入修改后的学生姓名: ")
|
||||||
|
student["sex"] = int(input("请输入修改后的学生性别:"))
|
||||||
|
student["number"] = int(input("请输入修改后的学生电话: "))
|
||||||
|
print("修改成功")
|
||||||
|
return 0
|
||||||
|
print("学生不存在")
|
||||||
|
return None
|
||||||
|
|
||||||
|
def exits():
|
||||||
|
print("退出系统")
|
||||||
|
return None
|
||||||
|
|
||||||
|
def search():
|
||||||
|
name = input("请输入您要查找的学生姓名:")
|
||||||
|
for student in class_info:
|
||||||
|
if student["name"] == name:
|
||||||
|
print("姓名:{}\n性别:{}\n电话:{}"
|
||||||
|
.format(student["name"], student["sex"], student["number"]))
|
||||||
|
return 0
|
||||||
|
print("学生不存在")
|
||||||
|
return None
|
||||||
|
|
||||||
|
def show():
|
||||||
|
print("%-5s%-5s%-10s" %("姓名", "性别", "电话"))
|
||||||
|
for student in class_info:
|
||||||
|
print("%-5s%-5d%-10d" %(student["name"],student["sex"], student["number"]))
|
||||||
|
|
||||||
|
def content():
|
||||||
|
with open(r"C:\Users\33365\Desktop\学生管理系统.txt", 'w',encoding="utf8")as f:
|
||||||
|
for i in class_info:
|
||||||
|
f.write(i)
|
||||||
|
|
||||||
|
|
||||||
|
def go():
|
||||||
|
while True:
|
||||||
|
choose =int(input("输入你需要的功能序号: "))
|
||||||
|
if choose==1:
|
||||||
|
add()
|
||||||
|
print(class_info)
|
||||||
|
elif choose==2:
|
||||||
|
# print(class_info)
|
||||||
|
dell()
|
||||||
|
elif choose == 3:
|
||||||
|
modify()
|
||||||
|
elif choose == 4:
|
||||||
|
search()
|
||||||
|
elif choose == 5:
|
||||||
|
# print(class_info)
|
||||||
|
show()
|
||||||
|
elif choose == 6:
|
||||||
|
content()
|
||||||
|
elif choose==7:
|
||||||
|
exits()
|
||||||
|
|
||||||
|
return None
|
||||||
|
go()
|
Loading…
Reference in new issue