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

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會(huì)有你想問的

Python可以同時(shí)使用__slots__與property么?

Python可以同時(shí)使用__slots__與property么?

qq_苦瓜_3 2016-12-13 17:58:20
class?Animal(object): ????__slots__?=?('name','age') ????def?__init__(self,name,age): ????????self.__name?=?name ????????self.__age?=?age ????@property ????def?name(self): ????????return?self.__name ????@name.setter ????def?name(self,value): ????????self.__name?=?value d?=?Animal('Tom',12) d.name?=?'Alice' print(d.name) Error>> AttributeError:?'Animal'?object?has?no?attribute?'_Animal__name'如果我這樣寫的話會(huì)報(bào)錯(cuò),那么如何正確實(shí)現(xiàn)slots 與 property?
查看完整描述

3 回答

  • 3 回答
  • 0 關(guān)注
  • 1515 瀏覽
慕課專欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

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

幫助反饋 APP下載

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

公眾號(hào)

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