|
|
# This is a sample Python script.
|
|
|
|
|
|
# Press Shift+F10 to execute it or replace it with your code.
|
|
|
# Press Double Shift to search everywhere for classes, files, tool windows, actions, and settings.
|
|
|
|
|
|
|
|
|
# def print_hi(name):
|
|
|
# # Use a breakpoint in the code line below to debug your script.
|
|
|
# print(f'Hi, {name}') # Press Ctrl+F8 to toggle the breakpoint.
|
|
|
#
|
|
|
#
|
|
|
# # Press the green button in the gutter to run the script.
|
|
|
# if __name__ == '__main__':
|
|
|
# print_hi('PyCharm')
|
|
|
#
|
|
|
# # See PyCharm help at https://www.jetbrains.com/help/pycharm/
|
|
|
# print("hello world")
|
|
|
# def age(n):
|
|
|
# if(n==1):
|
|
|
# c=10
|
|
|
# else:
|
|
|
# c=age(n-1)+2
|
|
|
# return c
|
|
|
# n=int(input())
|
|
|
# print(age(n))
|
|
|
student_info=[]
|
|
|
|
|
|
while True:
|
|
|
print("请选择如下功能:")
|
|
|
print("1.添加学员")
|
|
|
print("2.删除学员")
|
|
|
print("3.修改学员信息")
|
|
|
print("4.查询学员信息")
|
|
|
print("5.显示所有学员信息")
|
|
|
print("6.保存学员信息")
|
|
|
print("7.退出系统")
|
|
|
|
|
|
choice = input("请输入您需要的功能序号:")
|
|
|
|
|
|
if choice == "1":
|
|
|
name = input("请输入学员姓名:")
|
|
|
age = input("请输入学员年龄:")
|
|
|
num =input("请输入学员手机号:")
|
|
|
student_info.append({"姓名{} 年龄{} 手机号{}".format(name,age,num)})
|
|
|
print(student_info)
|
|
|
|
|
|
|
|
|
elif choice == "2":
|
|
|
name = input("请输入要删除的学员姓名:")
|
|
|
for student in student_info:
|
|
|
if student["姓名"] == name:
|
|
|
student_info.remove(student)
|
|
|
print("学员删除成功!")
|
|
|
break
|
|
|
else:
|
|
|
print("未找到该学员!")
|
|
|
|
|
|
elif choice == "3":
|
|
|
name = input("请输入要修改的学员姓名:")
|
|
|
for student in student_info:
|
|
|
if student["姓名"] == name:
|
|
|
new_name = input("请输入新的姓名(留空表示不修改):")
|
|
|
new_age = input("请输入新的年龄(留空表示不修改):")
|
|
|
new_num = input("请输入新的电话号码(留空表示不修改):")
|
|
|
if new_name:
|
|
|
student["姓名"] = new_name
|
|
|
if new_age:
|
|
|
student["年龄"] = new_age
|
|
|
if new_num:
|
|
|
student["手机号"] = new_num
|
|
|
print("学员信息修改成功!")
|
|
|
print(student_info)
|
|
|
break
|
|
|
else:
|
|
|
print("未找到该学员!")
|
|
|
|
|
|
elif choice == "4":
|
|
|
name = input("请输入要查询的学员姓名:")
|
|
|
for student in student_info:
|
|
|
if student["姓名"] == name:
|
|
|
print("学员信息:", student)
|
|
|
break
|
|
|
else:
|
|
|
print("未找到该学员!")
|
|
|
|
|
|
elif choice == "5":
|
|
|
print("所有学员信息:", student_info)
|
|
|
|
|
|
elif choice == "6":
|
|
|
print("学员信息已保存!")
|
|
|
|
|
|
elif choice == "7":
|
|
|
print("已退出!")
|
|
|
break
|
|
|
|
|
|
else:
|
|
|
print("输入错误,请输入1-7的数字") |