import sys
# 名字,年龄,电话,自动生成学号
a = 'py1807'
all_student = ['hjj', {'name': 'hjj', 'age': 12, 'phone': 1234, 'stu_id': 'py1807000'}]
num = 1
bian = '* '*30
f = '>>>>'
def add_student():
global num
pd = 1
global all_student
a = ''
while pd == 1:
stu_id = '%s%s' % (a, str(num).rjust(4, '0'))
stu_name = input('请输入学生姓名:'.rjust(19, ' '))
stu_age = input('请输入学生年龄:'.rjust(19, ' '))
stu_phone = input('请输入学生电话:'.rjust(19, ' '))
all_student.append(stu_name)
all_student.append({'name': stu_name, 'age': stu_age, 'phone': stu_phone, 'stu_id': '%s' % stu_id})
num = num+1
print('添加成功!!!'.rjust(19, ' '))
b = '1.继续添加'
c = '2.返回上一页'
pd11 = input('%s\n%s\n%s\n%s\n%s' % (bian.rjust(71, ' '), b.rjust(41, ' '), c.rjust(42, ' '), bian.rjust(71, ' '), f.rjust(41, ' ')))
if pd11 == '2':
break
elif pd11 == '1':
pass
else:
b = '你的输入有误返回到上一层'
print('%s\n' % b.rjust(44, ' '))
break
def select_student():
pd = 2
while pd == 2:
b = '1.查询所有学生信息'
c = '2.根据学生姓名查询信息'
pd_select = input('%s\n%s\n%s\n%s\n%s' % (
bian.rjust(71, ' '), b.rjust(41, ' '), c.rjust(42, ' '), bian.rjust(71, ' '), f.rjust(41, ' ')))
if pd_select == '1':
for x in all_student:
print(' '*10, x)
b = '1.继续查询'
c = '2.返回上一页'
pd11 = input('%s\n%s\n%s\n%s\n%s' % (
bian.rjust(71, ' '), b.rjust(41, ' '), c.rjust(42, ' '), bian.rjust(71, ' '), f.rjust(41, ' ')))
if pd11 == '2':
break
elif pd11 == '1':
pass
else:
b = '你的输入有误请重新输入'
print('%s\n' % b.rjust(44, ' '))
continue
elif pd_select == '2':
name_index = 0
stu_pd = 0
b = '请输入你想要查询的学生姓名:'
name_select = input('%s' % b.rjust(42, ' '))
for x in all_student:
name_index += 1
if name_select == x:
print(' '*10, all_student[name_index])
stu_pd = 1
if stu_pd == 0:
b = '你查找的学生不存在'
print('%s' % b.rjust(40, ' '))
b = '1.继续查询'
c = '2.返回上一页'
pd11 = input('%s\n%s\n%s\n%s\n%s' % (
bian.rjust(71, ' '), b.rjust(41, ' '), c.rjust(42, ' '), bian.rjust(71, ' '), f.rjust(41, ' ')))
if pd11 == '2':
break
elif pd11 == '1':
pass
else:
b = '你的输入有误返回到上一层'
print('%s\n' % b.rjust(44, ' '))
break
else:
b = '你的输入有误重新输入'
print('%s\n' % b.rjust(44, ' '))
continue
def delete_student():
pd = 3
while pd == 3:
pd_delete = input('请输入你想要删除的学生姓名:')
index = 0
name_index = []
name_pd = 0
if len(all_student) == 1:
print('学生信息为空无法进行删除操作,返回到主页面')
break
else:
for x in all_student[:]:
index += 1
if pd_delete == x:
name_index.append(index)
name_pd = 1
if name_pd == 0:
print('你输入的学生不存在,请重新输入')
continue
print(len(name_index))
for x1 in range(len(name_index)):
print('序号:%d' % name_index[x1], all_student[name_index[x1]])
qr_delete = input('请确认删除信息,输入序号进行删除,r.重新输入,q.返回上一层\n')
if qr_delete == 'r':
continue
elif qr_delete == 'q':
break
else:
if int(qr_delete) not in name_index[:]:
print(qr_delete, name_index)
print('你输入序号有误重新输入')
else:
del all_student[int(qr_delete)]
print('删除成功')
qr_1_delete = input('1.继续删除2返回上一层')
if qr_1_delete == '1':
continue
elif qr_1_delete == '2':
break
else:
print('输入信息有误返回到上一层!')
def manue(input_1):
while input_1 == 1:
print(' '*10, '* * * * * * * * * * * * hjj学生管理系统 * * * * * * * * * * *\n'
' * *')
b = '2.查找学生'
c = '3.删除学生'
d = '4.退出系统'
e = '* '*30
g = '* *'
a = '1.添加学生\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s' % (g.rjust(70, ' '), b.rjust(41, ' '), g.rjust(70, ' '),
c.rjust(41, ' '), g.rjust(70, ' '),d.rjust(41, ' '), e.rjust(71, ' '),
f.rjust(41, ' '))
pd1 = input(a.rjust(494, ' '))
if pd1 == '1':
add_student()
elif pd1 == '2':
select_student()
elif pd1 == '3':
delete_student()
elif pd1 == '4':
sys.exit()
else:
b = '你的输入有误请重新输入'
print('%s\n' % b.rjust(44, ' '))
pd1 = '1'
manue(1)
2018-10-14学生管理系统1.1
©著作权归作者所有,转载或内容合作请联系作者
- 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
- 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
- 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
推荐阅读更多精彩内容
- 【蝴蝶效应】 蝴蝶效应:上个世纪70年代,美国一个名叫洛伦兹的气象学家在解释空气系统理论时说,亚马逊雨林一只蝴蝶...
- 要求: 实现系统界面,功能界面,学号由迭代器或者生成器自动添加,实现添加学生、查询学生(按照姓名/学号查询)、修改...
- Shape 1. 释义 ①[N-COUNT 可数名词] form or outline of an object ...