class Project:
def __init__(self):
self .number = 1
self .name = "python"
self .teacher = "Mr.wang"
self .__place = "DingTalk"
def show(self):
print("""
课程编号:%d
课程名称:%s
任课教师:%s
上课地点:%s
""" %(self .number, self .name, self.teacher, self.__place)
)
project = Project()
print(project.show())
class Course:
def __init__(self, number, name, teacher, place):
self.number = number
self.name = name
self.teacher = teacher
self.__place = place
def __str__(self):
return '课程编号:%d\n课程名称:%s\n任课教师:%s\n上课地点:%s\n'%(self.number, self.name, self.teacher, self.__place)
myclass = Course(1, "python", "王老师", "线上")
print(myclass)
class Course:
def __init__(self,number,name,teacher,place):
self.number = number
self.name = name
self.teacher = teacher
self.__place = place
def show(self):
return '课程编号{}、课程名称{}、任课教师{}、上课地点{}'.format(self.number,self.name,self.teacher,self.__place)
a = Course (1,'python','王老师','学校')
b = Course (2, "math", "张老师", "qq")
c = Course (3, "English","靳老师", "DingTalk")
print(a.show() )
print(b.show() )
print(c.show() )