zoukankan      html  css  js  c++  java
  • Python dir()/help()

    dir()

    dir()用来查询一个类或者对象所有属性。你可以尝试一下

    print dir(list)
    

    返回的结果:

    ['__add__', '__class__', '__contains__', '__delattr__', '__delitem__', '__delslice__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__getitem__', '__getslice__', '__gt__', '__hash__', '__iadd__', '__imul__', '__init__', '__iter__', '__le__', '__len__', '__lt__', '__mul__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__reversed__', '__rmul__', '__setattr__', '__setitem__', '__setslice__', '__sizeof__', '__str__', '__subclasshook__', 'append', 'count', 'extend', 'index', 'insert', 'pop', 'remove', 'reverse', 'sort']
    

    help()

    help()用来查询的说明文档。你可以尝试一下

    print help(list)
    

    返回的结果:

    Help on class list in module __builtin__:
    
    class list(object)
     |  list() -> new empty list
     |  list(iterable) -> new list initialized from iterable's items
     |  
     |  Methods defined here:
     |  
     |  __add__(...)
     |      x.__add__(y) <==> x+y
     |  
     |  __contains__(...)
     |      x.__contains__(y) <==> y in x
     |  
     |  __delitem__(...)
     |      x.__delitem__(y) <==> del x[y]
     |  
     |  __delslice__(...)
     |      x.__delslice__(i, j) <==> del x[i:j]
     |      
     |      Use of negative indices is not supported.
     |  
     |  __eq__(...)
     |      x.__eq__(y) <==> x==y
     |  
     |  __ge__(...)
     |      x.__ge__(y) <==> x>=y
     |  
     |  __getattribute__(...)
     |      x.__getattribute__('name') <==> x.name
     |  
    
    (数据较多未全部显示)
    
  • 相关阅读:
    寄存器详解
    Sleep(0)的妙用
    源码分析之Dictionary笔记
    ASP.NET Core框架的本质
    Dictionary实现(收藏的)
    微软的判断一个数是不是质数的算法
    C#性能优化:延迟初始化Lazy
    C#3 分部方法,简单标记一下
    单例下并发的情况下访问私有变量的一个典型问题
    BeforeFieldInit的小叙
  • 原文地址:https://www.cnblogs.com/atsats/p/6103523.html
Copyright © 2011-2022 走看看