python's staticmethod

staticmethod function-static method is defined as a class method, the correct way is to use @staticmethod装饰器,这样在实例对象调用的时候,不会把实例对象本身传入静态方法的第一个参数了

Similar to the following, do not use the case of the example itself:

@staticmethod
def getStr(result):
if type(result) == tuple:
if type(result[0]) == tuple:
return result[0][0]
else:
return result[0]

Guess you like

Origin www.cnblogs.com/sylarwang/p/11819695.html