我是靠谱客的博主 愤怒小丸子,最近开发中收集的这篇文章主要介绍Python写的简单的学生成绩信息管理系统(简单版),觉得挺不错的,现在分享给大家,希望可以做个参考。

概述

import csv
import os
import pandas as pd
import operator
self_students=[]
self_students_new=[0]
def main():
main_login()
while True:
menu()
choice = input()
if choice == '0' :
break
elif choice == '1':
main_login()
print('此操作会删去之前所有值,请谨慎操作!!!')
inputlable()
write(csv_head3)
elif choice == '2':
inputinfo()
write(input_list)
elif choice == '3':
find_user()
elif choice == '4':
clean_name()
elif choice == '5':
demistake()
elif choice == '6':
len_num()
elif choice == '7':
main_login()
print_all()
elif choice == '8':
sort_goaldown()
elif choice == '9':
sort_goalup()
elif choice == '10':
go_by()
elif choice == '11':
csv_self()
elif choice == '12':
csv_goread()
else:
print('您输入的选项有错!!请重新输入!!')
def create_csv():
path = 'datemake.csv'
with open(path,'a',newline='',encoding='utf-8')as f:
csv_write = csv.writer(f)
def write(input_list):
with open('datemake.csv','a',newline='',encoding='utf-8') as f:
f_csv = csv.writer(f)
f_csv.writerow(input_list)
def write(csv_head3):
with open('datemake.csv','a',newline='',encoding='utf-8') as f:
f_csv = csv.writer(f)
f_csv.writerow(csv_head3)
def title():
print('
学生信息管理系统')
def lines(n):
print('=' * n)
def main_login():
if os.path.exists(r'datemake.csv'):
pass
else:
print('
尚未导入学生信息,请先选择功能1建立成绩项目再导入!!!')
create_csv()
def main_loginmake():
with open('datemake.csv','r',encoding='utf-8-sig')as f:
reader_take=csv.reader(f)
result_take=list(reader_take)
if result_take==[]:
print('
尚未导入学生信息,请先选择功能1建立成绩项目再选择功能2导入学生信息后使用!!!')
main()
else:
pass
def csv_reader():
main_loginmake()
global self_students
with open('datemake.csv','r')as f:
reader=csv.reader(f)
for row in reader:
self_students.append(row)
def menu():
title()
lines(50)
print("
0
退出系统")
print("
1
创建成绩项目(首次创建使用)")
print("
2
录入学生信息")
print("
3
查找学生信息")
print("
4
删除学生信息")
print("
5
修改学生信息")
print("
6
统计学生总人数")
print("
7
显示所有学生信息")
print("
8
按学生成绩高——低显示学生信息")
print("
9
按学生成绩低——高显示学生成绩")
print("
10
课程统计信息(每门课程平均分、最高分、最低分;每门课不及格百分比,优秀百分比)")
print("
11
保存学生信息到文件(student.csv)")
print("
12
从文件中读取数据(student.csv)")
lines(50)
print("请输入你的选择:",end='')
def inputlable():
#创建头文件(1)
global csv_head3
with open('datemake.csv','w',newline='',encoding='utf-8') as f:
f_csv = csv.writer(f)
csv_head1=[]
csv_head=['number','name','gender','age']
while True:
print("您要创建成绩项目吗(Y/N):",end='')
choice=input()
if choice=='N'or choice=='n':
print('操作成功!!!')
break
elif choice=='Y'or choice=='y':
addlable_key=input('您要输入的项目为:')
csv_head1.append(addlable_key)
csv_head3=csv_head+csv_head1
else:
print('您的选择有误!!!')
def inputinfo(): #录入学生信息功能(2)
main_loginmake()
global input_list
with open('datemake.csv','r',newline='',encoding='utf-8-sig')as f:
reader=csv.reader(f)
result=list(reader)
input_list=[]
number=input('number(输入back返回上一级菜单):')
if number=='back':
main()
with open('datemake.csv','r')as csvfiles:
reader11=csv.DictReader(csvfiles)
for row in reader11:
if row['number']==number:
print('该学号已存在!!!')
main()
input_list.append(number)
for i in result[0][1:]:
print(i,':',end='')
inputinfos=input()
input_list.append(inputinfos)
print('%s录入成功!!'%i)
def find_user():
#查找学生功能(3)
main_loginmake()
j=0
print('你想通过什么方式查找(姓名或学号)')
print('请输入你的选择(输入back返回上一级菜单):',end='')
choice=input()
if choice=='back':
main()
query_list=[]
if choice=='姓名':
print('请输入你要查询的姓名:',end='')
choice_name=input()
with open('datemake.csv','r')as csvfiles:
reader3=csv.DictReader(csvfiles)
for row in reader3:
if row['name']==choice_name:
query_list.append(row)
if query_list==[]:
print('未查询到该学生信息,请检查是否录入系统!!!')
else:
for i in query_list:
print(i)
elif choice=='学号':
print('请输入你要查询的学号:',end='')
choice_num=input()
with open('datemake.csv','r')as csvfiles:
reader3=csv.DictReader(csvfiles)
for row in reader3:
if row['number']==choice_num:
query_list.append(row)
if query_list==[]:
print('未查询到该学生信息,请检查是否录入系统!!!')
else:
for i in query_list:
print(i)
else:
print('输入选项有误或查询失败!!!')
def clean_name():
main_loginmake()
df=pd.read_csv('datemake.csv')
ji_time=-1
print('请输入你要操作的学号(输入back返回上一级菜单):',end='')
choice_num=input()
if choice_num=='back':
main()
with open('datemake.csv','r')as csvfiles:
reader3=csv.DictReader(csvfiles)
for row in reader3:
ji_time+=1
if row['number']==choice_num:
df_new=df.drop(df.index[ji_time], inplace=True)
df.to_csv('datemake.csv',index=0,encoding='utf-8')
print('删除成功!!!')
def demistake():
main_loginmake()
clean_name()
print('请重新录入信息')
inputinfo()
write(input_list)
def len_num():
main_loginmake()
filename='datemake.csv'
list1=[]
with open(filename,'r')as file:
reader=csv.DictReader(file)
list1=[row['number']for row in reader]
a=len(list1)
print('当前系统中共有%d人!!!'%a)
def print_all():
main_loginmake()
with open('datemake.csv','r')as csvfiles:
reader3=csv.DictReader(csvfiles)
for row in reader3:
print (row)
def sort_goaldown():
main_loginmake()
list_sortdown=[]
csv_reader()
print('你想对哪一门成绩进行降序排序(输入back返回上一级菜单):',end='')
choice=input()
if choice=='back':
main()
df=pd.read_csv('datemake.csv')
df=df.sort_values(choice)
df.to_csv('datemake_sort.csv',index=False)
with open('datemake_sort.csv','r')as f:
reader5=csv.reader(f)
result5=list(reader5)
sort_time=len(result5)
list_sort_down=[result5[0]]
for i in result5:
list_sort_down.append(result5[sort_time-1])
sort_time-=1
del list_sort_down[-1]
for row in list_sort_down:
print(row)
def sort_goalup():
main_loginmake()
csv_reader()
print('你想对哪一门成绩进行升序排序(输入back返回上一级菜单):',end='')
choice=input()
if choice=='back':
main()
df=pd.read_csv('datemake.csv')
df=df.sort_values(choice)
print(df)
def go_by():
main_loginmake()
print('请输入设定的及格成绩:',end='')
passing_score=float(input())
print('请输入设定的优秀成绩:',end='')
good_score=float(input())
csv_reader()
date=pd.read_csv('datemake.csv')
date.head(2)
date_new=date.drop(['number','name','gender','age'],axis=1)
date_new.to_csv('datemak_new.csv',index=0)
filename='datemak_new.csv'
list2=[]
list_sort=[]
with open('datemak_new.csv','r',encoding='utf-8-sig')as f:
reader15=csv.reader(f)
result=list(reader15)
go_time_csv=len(result[0])
for i in range(go_time_csv):
list1=list2=list_sort=[]
sum=0
dispassing_list=[]
good_list=[]
with open(filename,'r')as file:
reader=csv.reader(file)
list1=[row[i] for row in reader]
list1[0]=0
for j in list1:
sum+=float(j)
average=sum//(len(list1)-1)
list_sort.append(float(j))
if float(j) < passing_score:
dispassing_list.append(j)
if float(j) >good_score:
good_list.append(j)
list_sort.sort()
max=list_sort[-2]
min=list_sort[1]
dispassing_num=float(((len(dispassing_list))/(len(list_sort)-1))*100)
good_num=float(((len(good_list))/(len(list_sort)-1))*100)
print(result[0][i],'的平均分为:',average,',最大值为:',max,'最小值为:',min,'不及格百分比为:',dispassing_num,'%','优秀百分比为:',good_num,'%')
def csv_self():
main_loginmake()
df=pd.read_csv('datemake.csv')
df.to_csv('students.csv',index=0,encoding='utf-8')
print('保存信息到students.csv成功!!!')
def csv_goread():
csv_self()
main_loginmake()
goread=[]
df=pd.read_csv('students.csv')
df=df.sort_values('number')
print(df)
main()

期末的时候写的,还没有优化,先发了后面有时间了优化

最后

以上就是愤怒小丸子为你收集整理的Python写的简单的学生成绩信息管理系统(简单版)的全部内容,希望文章能够帮你解决Python写的简单的学生成绩信息管理系统(简单版)所遇到的程序开发问题。

如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(81)

评论列表共有 0 条评论

立即
投稿
返回
顶部