# Classes and objects
# object : There are properties ( features ) And the function / Method ( Behavior ), Is an instance of a class
# class : Keywords are class, Is a template for creating objects
class Human:
# Constructors , Initialization function
def __init__(self, breed, sex, height = '170'):# The default value is
# Define three attributes
self.breed = breed
self.sex = sex
self.height = height
# def __init__(self):
# # Define three attributes
# self.breed = None
# self.sex = None
# self.height = None
# Defined 3 A function
def study(self):
print(" Study ")
def eat(self):
print(" having dinner ")
def sleep(self):
print(" sleep ")
print(" One %s Blood type , Gender :%s, height :%s" % (self.breed, self.sex, self.height))
# The relationship between classes and objects : Class is the template for creating objects , Object is a cumulative instance
human = Human('A', ' Woman ')
# human.breed = 'A'
# human.sex = ' Woman '
# human.height = '170'
human.eat()
human.sleep()
human.study()
# Judgment function type()
print(type(human)) # Human type
print(type(human) == Human)
# isinstance Determine whether it is an instance ?
print(isinstance(human, Human)) # Parameters 1 It's the object , Parameters 2 Is a judged class
Yes Form Do more in-depth rese