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.
    
  • 相关阅读:
    mysql安装停在make[3]: Leaving directory `/mysql5.xx/mysqltest' 解决方法
    搞了个burst
    PKU2074
    PKU2029
    ACM/ICPC要求的知识点(转)
    PKU3264线段树解法
    PKU2036
    PKU1151线段树解法
    今天递了辞呈
    hamachi
  • 原文地址:https://www.cnblogs.com/zranguai/p/14947807.html
Copyright © 2011-2022 走看看