欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

学生管理系统 Python语言

程序员文章站 2023-11-22 12:55:52
def show_student(): print(('*'*20).center(55)) print('1.添加学生信息'.center(50)) print('2.修改学生信息'.center(50)) print('3.删除学生信息'.center(50)) print('4.查询学生信息' ......

def show_student():
print(('*'*20).center(55))
print('1.添加学生信息'.center(50))
print('2.修改学生信息'.center(50))
print('3.删除学生信息'.center(50))
print('4.查询学生信息'.center(50))
print('5.退出信息系统'.center(50))
print('6.显示学生信息'.center(50))
print(('*'*20).center(55))

def add_student():
a_name = input('please input the student name : ')
a_sex = input('please input the the sex :')
a_height = input('please input the height:')
add_diclt = {'name':a_name ,'sex':a_sex ,'height':a_height}
sum_list.append(add_diclt)
return sum_list
def alter_student():
al1 = 0
alte = input('please input the alter the student message name :')
for al in range(len(sum_list)):
if sum_list[al]['name'] == alte :
print(sum_list[al])
al1 = al
else:
if al == len(sum_list)-1:
print('do not find the student name ')
exit()
continue

a_name = input('please input the student name : ')
a_sex = input('please input the the sex :')
a_height = input('please input the height:')
add_diclt = {'name':a_name ,'sex':a_sex ,'height':a_height}
sum_list.insert(al1,add_diclt)
sum_list.pop(al1+1)
return sum_list
def del_student():
dll = 0
de_name = input('please input the del the student message name :')
for dl in range(len(sum_list)):
if sum_list[dl]['name'] == de_name:
print(sum_list[dl])
dll = dl
else:
if dl == len(sum_list)-1:
print('do not exit')
exit()
continue
sum_list.pop(dll)
print('删除成功!')
return sum_list
def find_student():
find_name = input('please input the find the student message name :')
for f1 in range(len(sum_list)):
if sum_list[f1]['name'] == find_name:
print(sum_list[f1])
else:
if f1 == len(sum_list)-1:
print('not find your input the name .please input continue')
find_student()
continue
return sum_list

def main_student():
while 1:
show_student()
s1 = input('please input the number:')
if s1 == '1':
print(add_student())
if s1 == '2':
print(alter_student())
if s1 == '3':
del_student()
if s1 == '4':
find_student()
if s1 == '5':
print('是否退出,如果退出输入y,如果继续,输入n ')
e1 = input('<<<')
if e1.upper() == 'y':
exit()
else:
show_student()
if s1 == '6':
print(sum_list)

sum_list = [] #总列表
lis1 = ['deng','123','taibai','123456','alex','2019','jing','2017']
lis2 = []
i = 3
while i > 0:
username = input('please input the username :')
password = input('please input the password : ')
if username in lis1[0::2] and password in lis1[1::2] :
print('验证成功...')
lis2.append(username)
lis2.append(password)
break
else:
i -= 1
print('验证失败,请再次尝试,您还有'+str(i)+'次机会')
continue
if i == 0:
exit()
print('欢迎{name}进入学生管理系统'.format(name = lis2[0]))
main_student()