函数子函数实例
class Dog(): def __init__(self,name,age): self.name=name self.age=age def sit(self): print(self.name.title()+' 现在坐下了') def roll_over(self): print(self.name.title()+' 现在打滚呢') myDog=Dog('kitty',2) print('我的狗名字是:'+myDog.name) print('我的狗年纪是:'+str(myDog.age)+'岁') myDog.sit() myDog.roll_over() youDog=Dog('haliy',10) print(youDog.name) print(str(youDog.age)) youDog.sit() youDog.roll_over()