摘要: Python中3种方式定义类方法, 常规方式, @classmethod修饰方式, @staticmethod修饰方式. class A(object): def foo(self, x): print("executing foo(%s,%s)" % (self, x)) print('self: 阅读全文
posted @ 2017-11-05 15:24 旅行的木讷 阅读(139) 评论(0) 推荐(0) 编辑
摘要: Python 除了拥有实例方法外,还拥有静态方法和类方法。 [python] view plain copy class Foo(object): def test(self)://定义了实例方法 print("object") @classmethod def test2(clss)://定义了类 阅读全文
posted @ 2017-11-05 15:12 旅行的木讷 阅读(124) 评论(0) 推荐(0) 编辑