<span id="mktg5"></span>

<i id="mktg5"><meter id="mktg5"></meter></i>

        <label id="mktg5"><meter id="mktg5"></meter></label>
        最新文章專題視頻專題問答1問答10問答100問答1000問答2000關鍵字專題1關鍵字專題50關鍵字專題500關鍵字專題1500TAG最新視頻文章推薦1 推薦3 推薦5 推薦7 推薦9 推薦11 推薦13 推薦15 推薦17 推薦19 推薦21 推薦23 推薦25 推薦27 推薦29 推薦31 推薦33 推薦35 推薦37視頻文章20視頻文章30視頻文章40視頻文章50視頻文章60 視頻文章70視頻文章80視頻文章90視頻文章100視頻文章120視頻文章140 視頻2關鍵字專題關鍵字專題tag2tag3文章專題文章專題2文章索引1文章索引2文章索引3文章索引4文章索引5123456789101112131415文章專題3
        問答文章1 問答文章501 問答文章1001 問答文章1501 問答文章2001 問答文章2501 問答文章3001 問答文章3501 問答文章4001 問答文章4501 問答文章5001 問答文章5501 問答文章6001 問答文章6501 問答文章7001 問答文章7501 問答文章8001 問答文章8501 問答文章9001 問答文章9501
        當前位置: 首頁 - 科技 - 知識百科 - 正文

        python函數-classmethod()

        來源:懂視網 責編:小采 時間:2020-11-27 14:28:39
        文檔

        python函數-classmethod()

        python函數-classmethod():classmethod(function)中文說明:classmethod是用來指定一個類的方法為類方法,沒有此參數指定的類的方法為實例方法,使用方法如下:class C: @classmethod def f(cls, arg1, arg2, ...): ... 類方法既可以直接類調用(C.f()),也可以進行
        推薦度:
        導讀python函數-classmethod():classmethod(function)中文說明:classmethod是用來指定一個類的方法為類方法,沒有此參數指定的類的方法為實例方法,使用方法如下:class C: @classmethod def f(cls, arg1, arg2, ...): ... 類方法既可以直接類調用(C.f()),也可以進行

        classmethod(function)

        中文說明:

        classmethod是用來指定一個類的方法為類方法,沒有此參數指定的類的方法為實例方法,使用方法如下:

        class C:
         @classmethod
         def f(cls, arg1, arg2, ...): ...

        類方法既可以直接類調用(C.f()),也可以進行實例調用(C().f())。

        版本:python2.2中新增,在python2.4中增加新功能。python3中仍可用。

        英文說明:

        Return a class method for function.

        A class method receives the class as implicit first argument, just like an instance method receives the instance. To declare a class method, use this idiom:

        class C:
         @classmethod
         def f(cls, arg1, arg2, ...): ...

        The @classmethod form is a function decorator – see the description of function definitions in Function definitions for details.

        It can be called either on the class (such as C.f()) or on an instance (such as C().f()). The instance is ignored except for its class. If a class method is called for a derived class, the derived class object is passed as the implied first argument.

        Class methods are different than C++ or Java static methods. If you want those, see staticmethod() in this section.

        For more information on class methods, consult the documentation on the standard type hierarchy in The standard type hierarchy.

        New in version 2.2.

        Changed in version 2.4: Function decorator syntax added.

        代碼實例:

        >>> class C:
        ... @classmethod
        ... def f(self):
        ... print "This is a class method"
        ...
        >>> C.f()
        This is a class method
        >>> c = C()
        >>> c.f()
        This is a class method
        >>> class D:
        ... def f(self):
        ... print " This is not a class method "
        ...
        >>> D.f()
        Traceback (most recent call last):
         File "", line 1, in 
        TypeError: unbound method f() must be called with D instance as first argument (got nothing instead)
        >>> d = D()
        >>> d.f()
        This is not a class method

        聲明:本網頁內容旨在傳播知識,若有侵權等問題請及時與本網聯系,我們將在第一時間刪除處理。TEL:177 7030 7066 E-MAIL:11247931@qq.com

        文檔

        python函數-classmethod()

        python函數-classmethod():classmethod(function)中文說明:classmethod是用來指定一個類的方法為類方法,沒有此參數指定的類的方法為實例方法,使用方法如下:class C: @classmethod def f(cls, arg1, arg2, ...): ... 類方法既可以直接類調用(C.f()),也可以進行
        推薦度:
        標簽: 函數 python class
        • 熱門焦點

        最新推薦

        猜你喜歡

        熱門推薦

        專題
        Top
        主站蜘蛛池模板: 亚洲精品成人片在线观看| h视频在线观看免费网站| 国产在线观看免费完整版中文版| 久久精品成人免费看| 国产网站在线免费观看| 亚洲欧美日韩中文字幕一区二区三区| 在线观看亚洲网站| 啦啦啦www免费视频| 亚洲一区二区三区高清在线观看 | 中文字幕精品亚洲无线码二区| 亚洲va久久久噜噜噜久久狠狠 | 色五月五月丁香亚洲综合网| 免费精品人在线二线三线区别| 亚洲人成色7777在线观看不卡| 中文字幕亚洲精品资源网| 最近免费中文字幕大全免费版视频 | 亚洲国产精品一区二区久久| 成人影片一区免费观看| 亚洲AV乱码一区二区三区林ゆな| 成人婷婷网色偷偷亚洲男人的天堂 | 国产成人亚洲综合色影视| 亚洲人成日本在线观看| 在线观看视频免费国语| 亚洲国产精品无码中文lv| 暖暖免费高清日本一区二区三区| 亚洲国产成人久久综合一 | 国产精品免费在线播放| 久久精品国产亚洲av麻豆 | 伊人久久综在合线亚洲2019| 免费阿v网站在线观看g| 免费无码午夜福利片| 亚洲精品国产精品乱码不99 | 2020久久精品亚洲热综合一本 | 一个人看的www免费高清| 亚洲日韩精品A∨片无码| 91精品免费高清在线| 亚洲乱码av中文一区二区| 亚洲综合无码AV一区二区 | 免费人成在线观看69式小视频| 亚洲熟妇无码另类久久久| 亚洲成人免费在线|