#coding:utf-8 class Person(object): def __init__(self,name,wage): self.name = name self.wage = wage def func(self): return '123' @property #方法变为属性 def attr(self): return '123' def computer(self): return '555' #类成员 (字段,方法,属性) obj = Person('jack',20000) print(obj.func()) print(obj.attr)
#类成员:方法 class Province(object): def __init__(self,name): pass def f1(self): #普通方法 pass @classmethod #类方法 def f2(cls): print("i am f2") print(cls) @staticmethod #静态方法 def f3(): print("i am f3") # obj = Province() # obj.f1() Province.f2() #调用都用类 Province.f3()