# -*- coding:utf-8 -*- class Teacher: def __init__(self,name,birthday,sex,cource): self.name = name self.birthday = birthday self.sex = sex self.cource = cource class Cource: def __init__(self,course_name,period,price): self.course_name = course_name self.period = period self.price = price class Birthday: def __init__(self,year,month,day): self.year = year self.month = month self.day = day b = Birthday(2019,1,16) c = Cource('python',6,800000) zhang = Teacher('张老师',b,'男',c) print(zhang.birthday.year) #可以通过zhang(对象)-(Teacher类)调用 Birthday里的属性 print(zhang.cource.price) #可以通过zhang(对象)-(Teacher类)调用 Cource里的属性