# 面向对象
# 有意义的面向对象的代码
# 类 = 面向对象
# 类、对象
# 实例化
# 类最基本的作用:封装
class Student():
name = ''
age = 0
def print_file(self):
print('name:' + self.name )
print('age:' + str(self.age) )
student = Student()
student.print_file()
如果想正确引用类里面定义的变量,我们需要使用 self 关键字,类里面的函数是一定要加self,否则会报错。如果想在函数内部使用类定义的变量,是需要在函数里面用 self.变量名

继承:
父类
class Human():
sum = 0
def __init__(self, name, age):
self.name = name
self.age = age
def get_name(self):
print(self.name)
def do_homework(self):
print('This is a parent Method')
子类


















