用Python实现链式调用:
class person():
def name(self,name):
self.name = name
return self
def age(self,age):
self.age = age
return self
def hobby(self,hobby):
self.hobby=hobby
return self
def show(self):
print("My name is",self.name,
"and age is",self.age,"years old.",
"My hobby is",self.hobby,"."
)
a = person()
a.name("pipi").age(18).hobby("study").show()