import my_functions
my_functions.sgister_sign_interface()
import json
# 注册(sgister)登录(sign)界面
def sgister_sign_interface():
choose_num = input('欢迎来到学生管理系统\n1.用户登录\n2.用户注册\n3.退出\n请选择:')
if choose_num == '1':
return sign_interface()
elif choose_num == '2':
return sgister_interface()
elif choose_num == '3':
return exit()
else:
print('输入有误')
return sgister_sign_interface()
# 登录界面函数
def sign_interface():
with open('./sign_num.json') as f:
sign_num = json.load(f)
n = input('请输入账号')
m = input('请输入密码')
for x in sign_num:
if n == x['sign_id']:
break
else:
print('无此账号')
return sign_interface()
if m == x['password']:
print('登陆成功')
return main_interface()
# 注册新用户界面函数
def sgister_interface():
n = input('请输入您要注册的账号:')
m = input('请输入您的密码:')
with open ('./sign_num.json') as f:
sign_num = json.load(f)
sgister_message = {'sign_id':n,'password':m}
sign_num.append(sgister_message)
with open('./sign_num.json','w') as f:
json.dump(sign_num,f)
k = input('注册成功\n1.直接登录\n2.返回上一级\n3.退出')
if k == '1':
return main_interface()
elif k == '2':
return sgister_sign_interface()
elif k == '3':
return exit()
else:
print('输入错误,将返回上级')
return sgister_sign_interface()
#主登录界面函数
def main_interface():
input_start = input('欢迎来到学生管理系统\n1.添加学生\n2.查找学生\n3.修改学生\n4.删除学生\nq.退出系统\n请输入序号进行操作:')
if int(input_start) == 1:
add_stu()
elif int(input_start) == 2:
search_student()
elif int(input_start) == 3:
print("333")
elif int(input_start) == 42:
print('444')
elif input_start == 'q':
print('qqq')
else:
print('输入有误')
return main_interface()
# 添加学生函数
def add_stu():
student = {'name': input_name, 'stu_id' : input_stu_id,'age': input_age, 'tel': input_tel}
input_name = input('请输入学生姓名')
input_stu_id = input("请输入学生学号")
if input_stu_id in message['stu_id']:
print('已有此学生!添加失败')
add_failed = input(':1.重新添加\n2.返回上级\n请输入:')
if int(add_failed) == '1':
return add_stu()
else:
return main_interface()
else:
input_age = input('请输入学生年龄')
input_tel = input('请输入学生电话')
message.append(student)
print('添加成功')
i += 1
add_success = input(':1.继续添加\n2.返回上级\nq.退出系统\n请输入:')
if int(add_success) == '1':
return add_stu() #返回添加函数本身
else:
return main_interface() #返回主界面函数
# 查询学生函数
def search_student():
input_name = input("请输入学生姓名")
i2 = 0
for x in message:
if input_name == x['name']:
print(message[i2])
i2 += 1
else:
i2 += 1
print('1.继续查询\n2.返回上级\nq.退出系统')
search_end = input("请选择操作:")
if int(search_end) == '1':
return search_student()
elif int(search_end) == '1':
return main_interface()
elif search_end == 'q':
exit()
else:
print('输入有误')
return main_interface()
# 删除学生函数
def delete_student():
input_name = input('请输入学生姓名')
i2 = 0
i3 = 0
del_search_result = []
for x in message:
del_search_student = {}
if input_name == x['name']:
print(i2,message[i3])
del_search_student[i2] = message[i3]#设置序号与信息的字典
del_search_result.append(del_search_student)
i2 += 1
i3 += 1
else:
i3 += 1
if len(del_search_result) == 0:
print('无学生可删除')
h = input('1.继续删除\n2.返回上级\nq.退出系统\n请选择要执行的操作:')
del_return_fun(h)
else:
index_def_stu = input('请输入要删除的学生序号')
for y in del_search_result:
if index_def_stu == y[0]:
del message[i3]
print('删除成功')
k = input('1.继续删除\n2.返回上级\nq.退出系统\n请选择要执行的操作:')
del_return_fun(k)
else:
print('输入有误')
g = input('1.继续删除\n2.返回上级\nq.退出系统\n请选择要执行的操作:')
del_return_fun(g)
# 删除学生的返回函数
def del_return_fun(m):
if m == '1':
return delete_student()
elif m == '2':
return main_interface()
elif m == 'q':
return exit()
else:
print('输入有误')
return main_interface()
网友评论