logon_list=[]
students = []
def welcom():
while True:
global logon_list
print('='*25)
print('杨永信电疗学校欢迎您'.center(14,' '))
print('1.登入'.center(14,' '))
print('2.注册'.center(14,' '))
print('3.退出'.center(14,' '))
print('=' * 25)
a=int(input('请输入指令:'))
if a==1:
logon_name = input('请输入用户名:')
logon_key = input('请输入密码:')
b={logon_name:logon_key}
if b in logon_list:
print('登入成功')
break
else:
print('账号密码错误!')
if a==2:
logon()
if a==3:
break
def logon():
global logon_list
logon_name=input('请设置用户名:')
logon_key=input('请设置密码:')
logon_list.append({logon_name:logon_key})
print('注册成功!')
return logon_list
def zjm():
print('='*25)
print('戒网瘾学校系统'.center(14,' '))
print('1.添加学生'.center(14,' '))
print('2.查看学生'.center(14,' '))
print('3.删除学生'.center(14,' '))
print('4.修改学生'.center(14,' '))
print('5.退出'.center(14,' '))
print('='*25)
def main_menu():
while True:
zjm()
a = int(input('请输入指令:'))
if a == 1:
stu_names = input('学生名字為:')
stu_ages = int(input('学生年龄为:'))
stu_phone = input('学生电话:')
student = {'name': stu_names, 'age': stu_ages, 'phone': stu_phone}
students.append(student)
print('添加成功')
continue
if a == 2:
b = input('请输入查看学生的名字:')
for c in students:
if b in c['name']:
print('学生的名字是', c['name'], '年龄为', c['age'], '电话为', c['phone'])
else:
print('未找到该学生')
continue
if a == 3:
b = input('请输入删除学生的名字:')
for c in students:
if b in c['name']:
del c['name']
del c['age']
del c['phone']
print('删除成功')
continue
if a == 5:
print('退出程序')
print('================================')
break
if a == 4:
b = input('请输入修改学生的名字:')
for c in students:
if b in c['name']:
print('学生的名字是', c['name'], '年龄为', c['age'], '电话为', c['phone'])
print('请输入更改信息')
print('1.更改年龄')
print('2.更改电话')
d=int(input('请输入选项'))
if d==1:
e=int(input('请输入新的年龄:'))
c['age']=e
print ('年龄修改成功!')
if d==2:
e = int(input('请输入新的电话:'))
c['phone'] = e
print ('年龄修改成功!')
else:
continue
welcom()
main_menu()
网友评论