现在该怎么办,请现在该做什么 如何追加感谢
students.append(s1)
students.append(s1)
students.append(s1)
students.append(s1)
students.append(s1)
students.append(s1)
students.append(s1)
students.append(s1)
students.append(s1)
students.append(s1)
答案 0 :(得分:1)
您可以向学生班级添加__str__
方法:
class student:
def __init__(self, code, name, number):
self.code = code
self.name = name
self.number = number
def __str__(self):
return '\t'.join((self.code, self.name, self.number))
students = []
s1 = student("901", "Joh Doe", "123456")
s2 = student("902", "Mary Mount", "566665")
s3 = student("903", "David Lee", "394624")
students.append(s1)
students.append(s2)
students.append(s3)
for student in students:
print student
答案 1 :(得分:0)
首先安装tabulate:
localhost
pip install tabulate