Python学员信息管理系统
"""
# 系统信息
1.添加学员
2.删除学员工
3.修改学员信
4.显示所有学员信息
5.查询所有学员信息
6.退出系统
"""
info = []
def system():
print('请选择您要的操作:')
print(' 1.添加学员')
print(' 2.删除学员')
print(' 3.修改学员信息')
print(' 4.查询学员')
print(' 5.显示所有学员')
print(' 6.退出系统')
def add_info():
global info
info_dict = {}
user_name = input('输入学员的名字:')
user_age = input('输入学员的年龄:')
user_phonumber = input('输入学员的电话号码:')
for i in info:
if user_name == i['name']:
print('该学员已经存在!')
return
info_dict['name'] = user_name
info_dict['age'] = user_age
info_dict['phonumber'] = user_phonumber
info.append(info_dict)
pass
def del_info():
global info
user_name = input('输入想要删除学员的名字:')
for i in info:
if i['name'] == user_name:
info.remove(i)
print('删除成功!!!')
return
else:
print("该学员不存在!!!")
pass
def modify_info():
global info
user_name = input('输入想要修改信息学员的名字:')
for i in info:
if i['name'] == user_name:
info.remove(i)
add_info()
print("修改成功!!!")
return
else:
print("该学员不存在!!!")
pass
def serch_info():
global info
user_name = input('输入想要查询学员的名字:')
for i in info:
if i['name'] == user_name:
print('他的名字是:%s,年龄是:%s,电话号码是:%s' % (i.get('name'), i.get('age'), i.get('phonumber')))
return
else:
print("该学员不存在!!!")
pass
def serch_allinfo():
global info
for i in info:
print('名字:%s,年龄:%s,电话号码:%s' % (i.get('name'), i.get('age'), i.get('phonumber')))
while True:
system()
user_num = int(input('您想输入的功能序号:'))
if user_num == 1:
add_info()
elif user_num == 2:
del_info()
elif user_num == 3:
modify_info()
elif user_num == 4:
serch_info()
elif user_num == 5:
serch_allinfo()
elif user_num == 6:
break
else:
print('输入有误!!!请重新输入')
|