类:模板
实例:实例类,在Python类中规定,函数的第一个参数是实例对象本身,并且约定俗成,把其名字写为self
对象:
class Student(object):
# self就是一个对象,对象里面有两个参数self.name,self.male
def __init__(self,name,male):
self.name = name
self.male = male
def intr(self):
sen = "i am " + self.name
return sen
#stu是Student的对象
stu = Student("liusiyan","female")
#stu代表一个实例
print(stu.intr())
# print(student.name)
python(14)类,方法,对象,实例 - 细雨微光 - 博客园 (cnblogs.com)https://www.cnblogs.com/lovychen/p/5417453.htmlPython 面向对象 | 菜鸟教程 (runoob.com)https://www.runoob.com/python/python-object.html