class Person: test=u"我是静态字段" def __init__(self,name): self.name=name print(u"我是构造函数") def hello(self): print("Hello World") @staticmethod def printf(): print(u"我是静态方法") def __del__(self): print(u"我是结束
test=u"我是静态字段"
def __init__(self,name):
self.name=name
print(u"我是构造函数")
def hello(self):
print("Hello World")
@staticmethod
def printf():
print(u"我是静态方法")
def __del__(self):
print(u"我是结束处理函数")
if __name__=="__main__":
print(Person.test)#静态字段的调用
Person.printf()#静态方法的调用