def __str__(self):
return '(Student: %s, %s, %s)' % (self.name, self.gender, self.score)
__repr__ = __str__
return '(Student: %s, %s, %s)' % (self.name, self.gender, self.score)
__repr__ = __str__
2018-01-27
print(list(filter(lambda x:x==x.strip('__'),dir(s))))
2018-01-27
def __init__(self, name, gender, **kw):
self.name = name
self.gender = gender
for k in kw:
setattr(self, k, kw[k])
self.name = name
self.gender = gender
for k in kw:
setattr(self, k, kw[k])
2018-01-27
class BStudent(BasketballMixin, Student):
pass
class FTeacher(FootballMixin, Teacher):
pass
pass
class FTeacher(FootballMixin, Teacher):
pass
2018-01-27
print isinstance(t, Person)
print isinstance(t, Student)
print isinstance(t, Teacher)
print isinstance(t, object)
print isinstance(t, Student)
print isinstance(t, Teacher)
print isinstance(t, object)
2018-01-27
class Teacher(Person):
def __init__(self, name, gender, course):
super(Teacher, self).__init__(name, gender)
self.course = course
def __init__(self, name, gender, course):
super(Teacher, self).__init__(name, gender)
self.course = course
2018-01-27
class Person(object):
__count = 0
@classmethod
def how_many(cls):
return cls.__count
def __init__(self, name):
self.name = name
Person.__count +=1
__count = 0
@classmethod
def how_many(cls):
return cls.__count
def __init__(self, name):
self.name = name
Person.__count +=1
2018-01-27
#encoding:utf-8
def __init__(self, name, score):
self.name = name
self.__score = score
def get_grade(self):
if self.__score < 60:
return 'C-不及格'
elif self.__score >= 80:
return 'A-优秀'
else:
return 'B-及格'
def __init__(self, name, score):
self.name = name
self.__score = score
def get_grade(self):
if self.__score < 60:
return 'C-不及格'
elif self.__score >= 80:
return 'A-优秀'
else:
return 'B-及格'
2018-01-27
老师,我打python出现的那天开始就一直在编程,这点知识点不在话下,你信不?不信?不信你咋不给人家多写一些讲解~
2018-01-26