【python】字典用屬性訪問方式訪問元素

python中的字典有key和value,咱們須要使用dict[key]的方式獲取value,書寫比較麻煩。 能夠改爲類的對像經過」."的形式來訪問字典元素。python class ObjDict(dict): """ Makes a dictionary behave like an object,with attribute-style access. """ def __g
相關文章
相關標籤/搜索