可以帮我修改一下代码吗
运行结果及报错内容
Traceback (most recent call last):
File "D:\python\课堂练习\exam02.py", line 42, in <module>
student=Student(name,age,num,score)
TypeError: Student() takes no arguments
class Student:
def _init_(self,name,age,num,score):
self.name=name
self.age=age
self.num=num
self.score=score
def _str_(self):
return '姓名:{} 年龄:{} 学号:{} 成绩:{}'.format(self.name,self.age,self.num,self.score)
class Class:
def _init_(self,name):
self.name=name
self.stu_list=[]
self.stu_dict={}
def add_stu(self,student):
self.stu_list.append(student)
self.stu_dict[stu.num]=student
def sort_stu(self,key,reverse):
self.stu_list.sort(key=key,reverse=reverse)
def del_stu(self,num):
s=self.stu_dict.pop(num)
self.stu_list.remove(s)
def show_stu(self):
for s in self.stu_list:
print(s)
def get_stu(self,num):
return self.stu_dict.get(num)
class_=Class()
def showui():
print('1.添加学生')
print('2.删除学生')
print('2.查看学生')
print('4.查找学生')
print('5.按照成绩排序')
while(1):
showui()
key=int(input('请输入数字:'))
if(key==1):
name=input('请输入学生姓名:')
age=int(input('请输入学生年龄:'))
num=int(input('请输入学生学号:'))
score=int(input('请输入学生成绩:'))
student=Student(name,age,num,score)
class_.add_stu(student)
if(key==2):
num=int(input('请输入要删除的学生学号:'))
class_.del_stu(num)
if(key==3):
class_.show_stu()
if(key==4):
num=int(input('请输入要查找的学生学号:'))
class_.get_stu(num)
if(key==5):
print('1.按照分数排列;2.按照年龄排列;3.按照学号排列')
temp=int(input('请选择数字来选择条件:'))
if temp==1:
class_.sort_stu(key=lambda s:s.score,reverse=True)
class_.show_stu()
if temp==2:
class_.sort_stu(key=lambda s:s.age,reverse=True)
class_.show_stu()
if temp==3:
class_.sort_stu(key=lambda s:s.num,reverse=True)
class_.show_stu()
if(key==6):
break
```)