python类变量、类方法、静态方法
class Demo(object):
host = 'omweex1'
def __init__(self,key,secret):
self.key = key
self.secret = secret
@staticmethod #静态方法
def getinfo():
print(Demo.host)
@classmethod #类方法
def getinfo2(cls):
print(cls.host)
if __name__ == '__main__':
#调用静态方法无需创建对象(方便作为工具类)无法使用self调取变量
Demo.getinfo()
#调用类方法无需创建对象 可以使用cls本对象Demo调取变量
Demo.getinfo()