python3 組合的個人理解
阿新 • • 發佈:2018-06-28
我不知道 .sh 問題 toolbar 類的組合 name 是你 person python3 python的組合在我看來和函數的嵌套差不多,也不知道這樣理解對還是不對,不對的希望各位大神幫我指正一下,謝謝了!
類的組合的主要作用是封裝前一個類的作用,其他的和函數的套用差不多!我是按照我的例子來理解的!!!
class Wear: def __init__(self,hat,clothes,trousers,shos): self.hat=hat self.clothes=clothes self.trousers=trousers self.shos=shos def wear(self): return ("喜歡 白%s帽子 黑%s衣服 紅%s褲子 藍%s鞋子"%(self.hat,self.clothes,self.trousers,self.shos)) class person: def __init__(self,name): self.name=name def show(self,hat,clothes,trousers,shos): s1=Wear(hat,clothes,trousers,shos)#我不知道你的類(或是你的函數是怎麽樣的,我就只知道我在我的類裏面調用你的方法來解決我的問題!) print(self.name,s1.wear()) a=person('小明') a.show('平底鍋','T恤','牛仔褲','繡花鞋')
python3 組合的個人理解