首页 > 编程语言 > 详细

python @staticmethod 注解,静态方法,可以省略类里那个self参数

时间:2020-05-03 00:58:39      阅读:96      评论:0      收藏:0      [点我收藏+]
class staticmethod(object):
    """
    staticmethod(function) -> method
    
    Convert a function to be a static method.
    
    A static method does not receive an implicit first argument.
    To declare a static method, use this idiom:
    
         class C:
             @staticmethod
             def f(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.
    
    Static methods in Python are similar to those found in Java or C++.
    For a more advanced concept, see the classmethod builtin.
    """

       

python @staticmethod 注解,静态方法,可以省略类里那个self参数

原文:https://www.cnblogs.com/DDBD/p/12819852.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!