题目内容
写出下列程序的运行结果:class Student:def __init__(self,sno,name):self.sno=snoself.name=namedef __str__(self):return '学号:'+self.sno+',姓名:'+self.nameif __name__=='__main__':ls1=[23,56,12,37,28]ls1.sort()print(ls1)ls1.sort(reverse=True)print(ls1)ls2=[Student('1810101','李晓明'), Student('1810100','马红'),Student('1810102','张刚')]ls2.sort(key=lambda stu:stu.sno)for stu in ls2:print(stu)ls2.sort(key=lambda stu:stu.sno, reverse=True)for stu in ls2:print(stu)
查看答案
搜索结果不匹配?点我反馈