定义类的方法

函数与方法的区别
函数 : 直接通过函数名称调用
方法 : 属于某个类 , 通过对象调用
对于方法的访问控制也是不提供的 , 类似于对属性的设置
class className(object):
def one(self):
pass
def _two(self):
pass
def __three(self):
pass
1
2
3
4
5
6
7
几个装饰器
@classmethod : 调用时 , 通过类名直接调用 , 不用通过声明类的对象间接调用
@property : 像调用属性一样调用方法 , 不用写方法后的括号
————————————————

猜你喜欢

转载自www.cnblogs.com/ly570/p/11408531.html
今日推荐