self
上一节
下一节
class Student():
def __init__(self , age):
self . age = age
st1 = Student(18)
print(st1.age)
self 就代表未来要产生的那个对象
1)函数参数有 self ,表示这个函数归属于未来的对象
2)self . age 是类中的长期变量
3)对象在运用变量时,就不能写成:self.age ,而要写成:st1.age
4)age 变量只是 __init__ 中的局部变量

