• python __builtins__ classmethod类 (11)


    11、'classmethod', 修饰符对应的函数不需要实例化,不需要 self 参数,但第一个参数需要是表示自身类的 cls 参数,可以来调用类的属性,类的方法,实例化对象等。

    class classmethod(object)
     |  classmethod(function) -> method
     |  
     |  Convert a function to be a class method.  # 将一个函数转换成类方法
     |  
     |  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, ...): | ... | | It can be called either on the class (e.g. C.f()) or on an instance | (e.g. C().f()). The instance is ignored except for its class.
    可以用类对象调用f函数,也可以实例对象调用f函数。 | 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 the staticmethod builtin. | | Methods defined here: | | __get__(self, instance, owner, /) | Return an attribute of instance, which is of type owner. | | __init__(self, /, *args, **kwargs) | Initialize self. See help(type(self)) for accurate signature. | | __new__(*args, **kwargs) from builtins.type | Create and return a new object. See help(type) for accurate signature. | | ---------------------------------------------------------------------- | Data descriptors defined here: | | __dict__ | | __func__ | | __isabstractmethod__
  • 相关阅读:
    SPRINGMVC整合SOLR
    solr 嵌套entity 高亮查询
    solr 高级进阶,解决问题
    Solr的主从模式Master-Slave
    Solr8.0速成系列 | Solr客户端常用操作和查询语法 08
    solr 的全量更新与增量更新
    solr8.0.0和tomcat8.5.40的整合,完整版
    设置 Tomcat 的JVM运行内存
    mongo主库地址变更,从库修改数据源IP
    mysql数据表如何导入MSSQL中
  • 原文地址:https://www.cnblogs.com/gundan/p/8243878.html
Copyright © 2020-2023  润新知