class Student: def __init__(self,name,age,sex,favorite): self.name_1 = name self.age_1 = age self.sex_1 = sex self.fav = favorite stu3 = Student('丽丽','10岁','女',['上语文课','看电影','打篮球']) stu4 = Student('强强','12岁','男',['上语文课','看电影','打篮球']) for i in stu3.fav: print('-'*10,stu3.name_1,',',stu3.age_1,',',stu3.sex_1,',','喜欢',i,'-'*10) for i in stu4.fav: print('-'*10,stu4.name_1,',',stu4.age_1,',',stu4.sex_1,',','喜欢',i,'-'*10)