ADD file via upload

main
pzkg37qfp 1 year ago
parent da87bdbdfc
commit fb450c9364

@ -0,0 +1,95 @@
from openpyxl import workbook
def menu():
print('-' * 30)
print('1. 添加学员信息')
print('2. 删除学员信息')
print('3. 修改学员信息')
print('4. 查询学员信息')
print('5. 显示所有学员信息')
print('6. 保存信息')
print('7. 退出系统')
print('-' * 30)
def add():
q = input("请输入学生的学号:")
a = input("请输入学生的姓名:")
b = input("请输入学生的性别:")
c = input("请输入学生的电话:")
student.append([q, a, b, c])
print("添加成功")
def delt():
a = input("请输入你要删除的学生的学号:")
for i in range(0, len(student) - 1):
if a in student:
del student[i]
print("删除成功")
else:
print("无该学生的学号")
def xiugai():
a1 = input("请输入你要修改学生的学号:")
for i in range(0, len(student) - 1):
if a1 == student[i][0]:
a = input("请输入你要修改的姓名:")
b = input("请输入你要修改的性别:")
c = input("请输入你要修改的电话号:")
student[i][1] = a
student[i][2] = b
student[i][3] = c
def search():
a = input("请输入你要查询学生的学号:")
for i in range(len(student)):
if a == student[i][0]:
print(f'学生的学号:{student[i][0]},学生的姓名:{student[i][1]},学生的性别:{student[i][2]},学生的电话:{student[0][3]}')
else:
print("无该学生的学号")
def allstu():
for i in range(len(student)):
print(
f'学生的学号:{student[i][0]},学生的姓名:{student[i][1]},学生的性别:{student[i][2]},学生的电话:{student[0][3]}')
def save():
fn = r"学生信息.xlsx"
wb = workbook.Workbook() # 创建工作簿
ws = wb.worksheets[0]
ws.title = "所有学生信息" # 更改表的名称
ws.append(["学号", "姓名", "性别", "电话"]) # 添加表头信息
for i in range(len(student)): # 前num名学校信息
u = student[i]
ws.append(u)
wb.save(fn) #
student = []
while True:
menu()
choice = int(input('请选择操作:'))
if choice == 1:
add()
elif choice == 2:
delt()
elif choice == 3:
xiugai()
elif choice == 4:
search()
elif choice == 5:
allstu()
elif choice == 6:
save()
elif choice == 7:
break
else:
print('输入错误,请重新输入!')
Loading…
Cancel
Save