久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

    • <bdo id='PyAn7'></bdo><ul id='PyAn7'></ul>

      <i id='PyAn7'><tr id='PyAn7'><dt id='PyAn7'><q id='PyAn7'><span id='PyAn7'><b id='PyAn7'><form id='PyAn7'><ins id='PyAn7'></ins><ul id='PyAn7'></ul><sub id='PyAn7'></sub></form><legend id='PyAn7'></legend><bdo id='PyAn7'><pre id='PyAn7'><center id='PyAn7'></center></pre></bdo></b><th id='PyAn7'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='PyAn7'><tfoot id='PyAn7'></tfoot><dl id='PyAn7'><fieldset id='PyAn7'></fieldset></dl></div>

        <small id='PyAn7'></small><noframes id='PyAn7'>

        <legend id='PyAn7'><style id='PyAn7'><dir id='PyAn7'><q id='PyAn7'></q></dir></style></legend>

        <tfoot id='PyAn7'></tfoot>

        從標準庫向 Python 字典添加屬性

        Adding an attribute to a Python dictionary from the standard library(從標準庫向 Python 字典添加屬性)
        <legend id='6FwOH'><style id='6FwOH'><dir id='6FwOH'><q id='6FwOH'></q></dir></style></legend>
          <bdo id='6FwOH'></bdo><ul id='6FwOH'></ul>

          <i id='6FwOH'><tr id='6FwOH'><dt id='6FwOH'><q id='6FwOH'><span id='6FwOH'><b id='6FwOH'><form id='6FwOH'><ins id='6FwOH'></ins><ul id='6FwOH'></ul><sub id='6FwOH'></sub></form><legend id='6FwOH'></legend><bdo id='6FwOH'><pre id='6FwOH'><center id='6FwOH'></center></pre></bdo></b><th id='6FwOH'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='6FwOH'><tfoot id='6FwOH'></tfoot><dl id='6FwOH'><fieldset id='6FwOH'></fieldset></dl></div>

          <tfoot id='6FwOH'></tfoot>
          • <small id='6FwOH'></small><noframes id='6FwOH'>

                    <tbody id='6FwOH'></tbody>
                  本文介紹了從標準庫向 Python 字典添加屬性的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  我想知道是否可以向 Python 字典添加屬性?

                  I was wondering if you could add an attribute to a Python dictionary?

                  class myclass():
                      def __init__(): 
                       self.mydict = {}  # initialize a regular dict
                       self.mydict.newattribute = "A description of what this dictionary will hold"
                       >>> AttributeError: 'dict' object has no attribute 'newattribute'
                       setattr(self.mydict, "attribute", "A description of what this dictionary will hold"
                       >>> AttributeError: 'dict' object has no attribute 'newattribute'
                  

                  有沒有辦法快速添加我的描述屬性,而不必復制 dict 類和重載構造函數.我以為這很簡單,但我想我錯了.

                  Is there anyway to quickly add my description attribute without having to copy the dict class and overloading the constructor. I thought it would be simple, but I guess I was wrong.

                  推薦答案

                  直接派生自dict:

                  class MyDict(dict):
                      pass
                  

                  MyDict 實例的行為類似于 dict,但可以具有自定義屬性:

                  Instances of MyDict behave like a dict, but can have custom attributes:

                  >>> d = MyDict()
                  >>> d.my_attr = "whatever"
                  >>> d.my_attr
                  'whatever'
                  

                  這篇關于從標準庫向 Python 字典添加屬性的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

                  【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

                  相關文檔推薦

                  python: Two modules and classes with the same name under different packages(python:不同包下同名的兩個模塊和類)
                  Configuring Python to use additional locations for site-packages(配置 Python 以使用站點包的其他位置)
                  How to structure python packages without repeating top level name for import(如何在不重復導入頂級名稱的情況下構造python包)
                  Install python packages on OpenShift(在 OpenShift 上安裝 python 包)
                  How to refresh sys.path?(如何刷新 sys.path?)
                  Distribute a Python package with a compiled dynamic shared library(分發帶有已編譯動態共享庫的 Python 包)

                    1. <legend id='08wcd'><style id='08wcd'><dir id='08wcd'><q id='08wcd'></q></dir></style></legend>
                    2. <tfoot id='08wcd'></tfoot>
                      • <small id='08wcd'></small><noframes id='08wcd'>

                          <tbody id='08wcd'></tbody>
                        <i id='08wcd'><tr id='08wcd'><dt id='08wcd'><q id='08wcd'><span id='08wcd'><b id='08wcd'><form id='08wcd'><ins id='08wcd'></ins><ul id='08wcd'></ul><sub id='08wcd'></sub></form><legend id='08wcd'></legend><bdo id='08wcd'><pre id='08wcd'><center id='08wcd'></center></pre></bdo></b><th id='08wcd'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='08wcd'><tfoot id='08wcd'></tfoot><dl id='08wcd'><fieldset id='08wcd'></fieldset></dl></div>

                            <bdo id='08wcd'></bdo><ul id='08wcd'></ul>
                            主站蜘蛛池模板: 玖玖玖av| 国产精品一区二区久久精品爱微奶 | 一级黄a| 人干人人 | 日本欧美黄色片 | 国产免费va | 日韩精品视频在线播放 | 97视频人人澡人人爽 | 国产一区二区三区 | 一区二区三区视频在线 | 亚洲精品68久久久一区 | 婷婷综合色 | 亚洲国产一区二区三区在线观看 | 91九色麻豆 | 色综合天天天天做夜夜夜夜做 | 视频一区二区三区四区五区 | 91在线观看视频 | 精品美女久久久 | 午夜国产羞羞视频免费网站 | 日韩精品一区二区三区在线观看 | 永久精品| 亚洲97| 免费视频一区二区 | 国产一区二 | 亚洲成人播放器 | 国产在线视频一区二区董小宛性色 | а_天堂中文最新版地址 | 日韩精品一区二区三区中文在线 | 久久久国产一区二区三区四区小说 | 日韩成人免费 | 国产偷录视频叫床高潮对白 | 黄色一级大片在线免费看产 | 日韩精品成人网 | 国产精品久久久精品 | 欧美福利视频一区 | 亚洲精品国产综合区久久久久久久 | 无码一区二区三区视频 | av 一区二区三区 | 欧美在线视频一区二区 | 亚洲一二三区精品 | 北条麻妃一区二区三区在线观看 |