第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定

為什么這個(gè)代碼,輸出后是<呢?

#?Enter?a?codeclass?Animal(object):????
def?__init__(self,age,name,location):????????
????self.__age?=?age????????
????self.__name?=?name????????
????self.__location?=?location
????
????#Defined?the?fuction?that?can?get?the?details????
????def?get_age(self):????????
????????return?self.__age????
????def?get_name(self):????????
????????return?self.__name????
????def?get_location(self):????????
????????return?self.__location????
????def?get_details(self):????????
????????print('name:{},age:{},location:{}'.format(self.get_name,self.get_age,self.get_location))
????
????
????#Defined?the?fuction?that?can?modify?the?instance????
????def?set_age(self,age):????????
????????self.__age?=?age????
????def?set_name(self,name):????????
????????self.__name?=?name????
????def?set_location(self,location):????????
????????self.__location?=?location???????
????
?dog?=?Animal(18,'Jack','Asia')
?print(dog.get_details)


正在回答

3 回答

class?Animal(object):????????
????def?__init__(self,age,name,location):????????????????
????????self.__age?=?age????????????????
????????self.__name?=?name????????????????
????????self.__location?=?location?????
????def?get_age(self):????????????????
????????return?self.__age????????
????def?get_name(self):????????????????
????????return?self.__name????????
????def?get_location(self):
????????return?self.__location????????
????def?get_details(self):????????????????
????????print('name:{},age:{},location:{}'.format(self.get_name(),self.get_age(),self.get_location()))????????????????
????def?set_age(self,age):????????????????
????????self.__age?=?age????????
????def?set_name(self,name):????????????????
????????self.__name?=?name????????
????def?set_location(self,location):????????????????
????????self.__location?=?location???????????

dog?=?Animal(18,'Jack','Asia')
dog.get_details()


0 回復(fù) 有任何疑惑可以回復(fù)我~

方法 get_details(self) 中,self.get_name,self.get_amge, self.get_location調(diào)用是屬性,而并沒有定義這個(gè)屬性,所以打印出應(yīng)該是'name:,age:,location:'才對(duì)。如果調(diào)用方法,就是少了括號(hào)

0 回復(fù) 有任何疑惑可以回復(fù)我~

輸出后是> 不好意思 打錯(cuò)了

1 回復(fù) 有任何疑惑可以回復(fù)我~
#1

慕瓜5292660

一樣的情況
2021-10-13 回復(fù) 有任何疑惑可以回復(fù)我~

舉報(bào)

0/150
提交
取消

為什么這個(gè)代碼,輸出后是<呢?

我要回答 關(guān)注問題
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)