class Course():
def __init__(self,course_number,course_name,tearcher,address):
self.course_number = course_number
self.course_name = course_name
self.tearcher = tearcher
self.__address = address #私有变量
def printinfo(self):
print('course_number:'+self.course_number)
print('course_name:'+self.course_name)
print('teacher:'+self.tearcher)
print('address:'+self.__address)
information = input(“课程码,课程名称,老师,上课地点用空格隔开”).split(" ")
course1 = Course(*information) #解包传参
course1.printinfo()
用类写一个课程信息系统实现增加和查找
最新推荐文章于 2021-02-05 05:27:18 发布