day13-作业-学生管理系统(粗略)

def start_log():
print('============学生管理系统============')
print(' 1.注册 ')
print(' 2.登录 ')
print(' 3.退出 ')
print('===================================')

def register():
print('==============注册页面==============')
with open('files/users.txt', 'r', encoding='utf-8') as f:
users = eval(f.read())
while True:
user_name = input('用户名:')
pw = input('密码:')
for x in users:
if x == user_name:
print('该用户已经注册,请重新注册')
break
else:
users[user_name] = pw
print('注册成功')
break
with open('files/users.txt', 'w', encoding='utf-8') as f:
f.write(str(users))
return log()

def judge_ope(n):
if n == 1:
return register()
elif n == 2:
return log_in()
elif n == 3:
return 0

def log_in():
print('==============登录页面==============')
with open('files/users.txt', 'r', encoding='utf-8') as f:
users = eval(f.read())

account = input('请输入用户名:')
password = input('请输入密码:')
count = 0
for x in users:
    if account == str(x) and password == str(users[x]):
        count = 1
    elif account == str(x) and password != str(users[x]):
        count = 2

if count == 1:
    print('登录成功')
    return manager(account)
elif count == 2:
    print('密码错误,请重新登录')
    return log_in()
elif count == 0:
    print('用户名错误,请重新登录')
    return log_in()

def log():
while True:
start_log()
n = int(input('请输入你要进行的操作:'))
judge_ope(n)
if judge_ope(n) == 0:
break

def manager(xx):
print('============学生管理页面=============')
print('欢迎%s老师' % xx)
print(' 1.添加学生')
print(' 2.查看学生')
print(' 3.修改学生信息')
print(' 3.修改学生信息')
print(' 5.返回')
print('====================================')
n2 = int(input('请输入你要进行的操作(1-5):'))
judge_ope2(n2)

def judge_ope2(n):
if n == 1:
return add_stu()
elif n == 2:
return look_stu()
elif n == 3:
return modification_stu()
elif n == 4:
return del_stu()
elif n == 5:
return log()

def add_stu():
account = input('请输入要添加的学生姓名')
pass

def look_stu():
account = input('请输入要查看的学生姓名')
pass

def modification_stu():
account = input('请输入要修改的学生姓名')
pass

def del_stu():
account = input('请输入要删除的学生姓名')
pass

def add_stu():
account = input('请输入要添加的学生姓名')
pass

log()

你可能感兴趣的:(day13-作业-学生管理系统(粗略))