<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
        主站蜘蛛池模板: 中文字幕亚洲一区二区三区| 亚洲日本乱码卡2卡3卡新区| 亚洲色欲色欲www在线丝 | 少妇人妻偷人精品免费视频| 台湾一级毛片永久免费| 亚洲日本va午夜中文字幕久久| 亚洲第一页中文字幕| 国产精品hd免费观看| 成人激情免费视频| 亚洲av福利无码无一区二区| 在线观看亚洲免费视频| 久久国产色AV免费看| 亚洲中文字幕无码永久在线| 亚洲人成色777777老人头| 99视频在线免费| 国产亚洲一区二区三区在线| 国产精品亚洲一区二区三区久久| 国产成人免费网站在线观看| 国产成人精品日本亚洲网址| 一级毛片免费观看不卡视频| 亚洲精品在线播放视频| 手机在线免费视频| 欧洲精品码一区二区三区免费看| 最近免费中文字幕4| 羞羞网站在线免费观看| 大陆一级毛片免费视频观看| 亚洲国产日韩在线成人蜜芽| 久久国产乱子伦精品免费一 | 亚洲免费观看视频| 在线观看免费视频资源| 亚洲天天做日日做天天看| 两性色午夜免费视频| 国产成人毛片亚洲精品| 久久久久免费精品国产小说| 亚洲色欲啪啪久久WWW综合网| 久久经典免费视频| 日亚毛片免费乱码不卡一区 | 亚洲图片在线观看| 国产精品视频永久免费播放| 亚洲va精品中文字幕| 国产成人精品免费视|