zoukankan      html  css  js  c++  java
  • python

    __doc__

    # __doc__
    #摘要信息
    #这个属性不会继承给子类
    
    class Test():
        """这是摘要信息"""
        pass
    
    x = Test()
    print(x.__doc__)

    __module__

    # __module__
    #查看类的出处
    
    #从当前路径下test文件中,导入Test2 类
    from test import Test2
    x = Test2()
    #查看x.__module__参数:
    print(x.__module__)
    #显示test
    
    # __class__
    # 查看类的出处
    print(x.__class__)

    __del__析构方法

    #析构方法
    # __del__
    #当对象在内存中被释放时,自动触发执行.
    
    class Test():
        x = "test"
    
        def __del__(self):
            print("执行__del__方法~~~~~~")
    
    x = Test()
    #程序执行完毕后
    print(x.x)
    #执行了__del__方法

    __cal__

    # __cal__
    # 对象后面加括号,触发执行
    
    class Test():
        def __call__(self, *args, **kwargs):
            print("__call__方法执行..")
    
    #没有触发类执行__call__ 方法
    print(Test())
    
    #触发__call__方法
    x = Test()
    x()
  • 相关阅读:
    匿名方法
    C# 正则表达式
    c# 预处理命令
    反射
    特性(attribute)
    c# 交换两个变量
    构造函数
    泛型
    Event事件
    委托
  • 原文地址:https://www.cnblogs.com/Anec/p/9788618.html
Copyright © 2011-2022 走看看