@staticmethod 静态方法 函数修饰符,用来修饰一个函数,类似于装饰器 class Dog(object): def __init__(self,name): self.name = name def eat(self,food): print('%s is eating %s'%(self.name,food)) d = Dog('二哈') d.eat('包子') #二哈 is eating 包子 eat()方法上面加上 @staticmethod class Dog(object)…
一.staticmethod(function) Return a static method for function.A static method does not receive an implicit first argument. To declare a static method, use this idiom: class Sing(): @staticmethod def sayHello(): print "hello world" def sayNo(): pr…