05
方法的可访问性
shout(selft)
shout() 是一个 public 方法, 或者可在外部被其他模块调用的方法.
__shout(selft)
如果在 shout 前加 2 个_后, 此方法变为私有方法, 只能在内部使用.
__type
属性前加 2 个_后, 属性变为私有属性, 通过这个可改变属性的可读可写属性.
def get_type(self) :
return __type
这样后, 相当于 type 是可读不可写的.
来源: https://mp.weixin.qq.com/s?__biz=MzI3NTkyMjA4NA==&mid=2247485122&idx=1&sn=d511380e8d77b22b8c6ab52775842471&chksm=eb7c2b09dc0ba21f7b48a652944cab29be1baf75e183dbb9d1baba12aa05ee8fc9226478788f#rd