import csv
def getinfo():
stu = []
with open("stu_score.csv", encoding = 'utf-8') as f:
csr = csv.reader(f)
for i in csr:
stu.append(i)
return stu
class Student():
def __init__(self, name, num, score, ):
self.name = name
self.num = num
self.score = score
def get_name(self) :
return self.name
def get_num(self):
return self.num
def get_high_score(self):
return max(map(int, self.score))
stu = getinfo()
for i in stu:
print(i)
for i in stu[1:]:
s = Student(i[0], i[1], i[2:])
print(f"姓名:{s.get_name()} 学号:{s.get_num()} 最高分数:{s.get_high_score()}")
--result
['姓名', '学号', '语文', '数学', '英语', '科学']
['张山', '0001', '80', '90', '98', '67']
['李思', '0002', '95', '93', '88', '87']
['王武', '0003', '95', '86', '92', '90']
['赵露', '0004', '86', '92', '96', '77']
姓名:张山 学号:0001 最高分数:98
姓名:李思 学号:0002 最高分数:95
姓名:王武 学号:0003 最高分数:95
姓名:赵露 学号:0004 最高分数:96