zoukankan      html  css  js  c++  java
  • dir函数

    dir函数返回任意对象的属性和方法列表,包括模块对象、函数对象、字符串对象、列表对象、字典对象。。。等

    1,

    class test:
        def func(self):
            pass
        def __dir__(self):
            return ['a','b','c']
    a=test()   
    print(dir(a))   #['a', 'b', 'c']
    print(dir(test))#['__class__', '__delattr__', '__dict__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__',

    # '__gt__', '__hash__', '__init__', '__le__', '__lt__', '__module__', '__ne__', '__new__', '__reduce__', '__reduce_ex__',
    #'__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', '__weakref__', 'func']

    2,

    In [1]: import math
    
    In [2]: dir()
    Out[2]:
    ['In',
     'Out',
     '_',
     '__',
     '___',
     '__builtin__',
     '__builtins__',
     '__doc__',
     '__name__',
     '_dh',
     '_i',
     '_i1',
     '_i2',
     '_ih',
     '_ii',
     '_iii',
     '_oh',
     '_sh',
     'exit',
     'get_ipython',
     'math',
     'quit']

    3,

    In [3]: dir(math)
    Out[3]:
    ['__doc__',
     '__name__',
     '__package_
     'acos',
     'acosh',
     'asin',
     'asinh',
     'atan',
     'atan2',
     'atanh',
     'ceil',
     'copysign',
     'cos',
     'cosh',
     'degrees',
     'e',
     'erf',
     'erfc',
     'exp',
     'expm1',
     'fabs',
     'factorial'
     'floor',
     'fmod',
     'frexp',
     'fsum',
     'gamma',
     'hypot',
     'isfinite',
     'isinf',
     'isnan',
     'ldexp',
     'lgamma',
     'log',
     'log10',
     'log1p',
     'modf',
     'pi',
     'pow',
     'radians',
     'sin',
     'sinh',
     'sqrt',
     'tan',
     'tanh',                                            
     'trunc']
  • 相关阅读:
    原生内存泄漏检测
    安卓适配
    游戏里的动态阴影-ShadowMap实现原理
    游戏里的跨地图寻路算法
    Unity-Shader-动态阴影(上) 投影的矩阵变换过程
    Unity-奥义技能背景变黑效果
    UGUI学习笔记
    Unity-Shader-镜面高光Phong&BlinnPhong-油腻的师姐在哪里
    Unity-Shader-光照模型之漫反射
    Unity3D-Shader-热扭曲效果
  • 原文地址:https://www.cnblogs.com/sklww/p/3731003.html
Copyright © 2011-2022 走看看