python:编写程序,使字典储存学生信息,学生信息包括学号和姓名,根据学号从小到大输出学生信息
2个回答
2018-11-21
展开全部
dict={}
class student(object):
def __init__(self,number,name):
self.name=name
self.number=number
def Dict(self):
dict[self.number]=self.name
def Student(number,name):
a=student(number,name).Dict()
def sort():
test=[]
for i in dict:
test.append(i)
test.sort()
for i in test:
print(i,dict[i])
Student('3','T1')
Student('2','T2')
Student('1','T3')
Student('4','T4')
print(dict)
sort()
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询