class Geese: '''大雁类''' def __init__(self,beak,wing,claw): print("我是大雁类!我有以下特征:") print(beak) print(wing) print(claw) def fly(self,state): print(state) beak_1 = "嘴的基部较高,长度和头部的长度几乎相等" wing_1 = "翅膀长而尖" claw_1 = "爪子是蹼状" wildGoose = Geese(beak_1,wing_1,claw_1) wildGoose.fly("我飞行的时候,一会儿排成个人字,一会儿排成个一字")
实例2
class Geese: '''雁类''' neck = "脖子较长" wing = "振翅频率高" leg = "腿位于身体的中心支点,行走自如" number = 0 def __init__(self): Geese.number +=1 print("/n我是第"+str(Geese.number)+"大雁,我是属于雁类!我有以下特征:") print(Geese.neck) print(Geese.wing) print(Geese.leg) list1 = [] for i in range(4): list1.append(Geese()) print("一共有"+str(Geese.number)+"只大雁")
实例3
class TVshow: list_film = ["战狼","红海行动","西游记女儿国","熊出没 变形记"] def __init__(self,show): self._show = show @property def show(self): return self._show @show.setter def show(self,value): if value in TVshow.list_film: self.__show ="您选择了《"+value +"》,稍后将播放" else: self.__show ="您点播的电影并不存在" tvshow = TVshow("战狼") print("正在播放:《",tvshow.show,"》") print("你可以从",tvshow.list_film,"中选择要点播的电影") tvshow.show ="红海行动" print(tvshow.show)
标签:__,Geese,show,self,第七章,print,wing From: https://www.cnblogs.com/3077721976LSQ/p/16809905.html