Python_面向对象_类Person类_高博培训中...
面向对象_类_Person类
class Person:
tel = 181111111111
def __init__(self,name,age,address):
self.name = name
self.age = age
self.address = address
def show(self):
print(self.name,self.age,self.address)
@classmethod
def showObject(cls):
print("这是一个class method")
@staticmethod
def showStatic():
print("这是一个static method")
tom = Person('yinkai',18,'CN')
tom.show()
print(tom.name)
print(Person.tel)
print(tom.tel)
Person.showObject()
tom.showObject()
Person.showStatic()
tom.showStatic()