zoukankan      html  css  js  c++  java
  • python杂项

    -- 命名惯例:

        以单一下划线开头的变量名(_X)不会被from module import*等语句导入
        前后有两个下划线的变量名(__X__)是系统定义的变量名,对解释器有特殊意义
        以两个下划线开头但不以下划线结尾的变量名(__X)是类的本地(私有)变量
    

    导入模块

    • 从别的文件中导入模块:
      • 绝对导入
    import sys
    
    sys.path.append(r'D:老男孩python22期代码及笔记python-learningday14b')  # r防止转义
    print(sys.path)
    import kk
    
    • 相对导入
    sys.path.append(r'../../day14/bb')
    

    2021年11月23号 20:43加

    在学习mmdetection源码中遇到的关于hook函数中的getattr(hook, hook_name)(self)

    • 根据下面的官方解释,使用getattr(x, 'foobar')等同于使用x.foobar
    getattr(object, name[, default]):
    Return the value of the named attribute of object. name must be a string. 
    If the string is the name of one of the object’s attributes, the result is the value of that attribute. 
    For example, getattr(x, 'foobar') is equivalent to x.foobar. 
    If the named attribute does not exist, default is returned if provided, otherwise AttributeError is raised.
    
  • 相关阅读:
    867-转置矩阵
    704-二分查找
    选择排序
    999-车的可用捕获量
    66-加一
    观察者模式(1)
    命令模式(3)-宏命令
    命令模式(2)-命令接口中的撤销方法
    接口测试
    移动端测试
  • 原文地址:https://www.cnblogs.com/zranguai/p/14947807.html
Copyright © 2011-2022 走看看