python类基础之classmethod、staticmethod使用
一、类三种方法
1、实例方法:写在类里面,比如
def __init__(self, url): def instance(self):
带有self标志。应用:给类实例使用,需要实例化。可以调用静态方式
2、类方法:需要classmethod装饰,比如
@classmethod
def func_for_class(cls)
cls相当于类名Obj 。应用:给类使用,...
原创
2019-09-27 20:43:08 ·
222 阅读 ·
1 评论