一、使用Property的目的
@property使得函数方法变成数据属性。
二、@Property具体使用方法
对实例属性操作时,可通过getter和setter来实现读写属性
@property+定义setter方法--》具有读和修改属性
@property+定义getter方法--》只读属性
@property ----》只读属性
下方这道练习题中,注意一点:
@property将一个声明的方法def width(self)变成了一个属性width
为了避免属性名和方法重名,在返回变量前加_。