两种声明方式:
1.在类中声明一个函数 然后 foo = staticmethod(foo)
2.在函数声明定义的前一行加 @staticmethod
class TestStaticMethon:
@staticmethod
def foo():
print 'static methond'
#foo = staticmethod(foo)
class TestClassMethon:
@classmethod
def foo(cls):
print 'foo() is the class method'
#foo = classmethod(foo)
tsm = TestStaticMethon()
TestStaticMethon.foo()
tsm.foo()
tc = TestClassMethon()
TestClassMethon.foo()
tc.foo()