zoukankan      html  css  js  c++  java
  • Python DIR

    If you cannot sure the method of a datatype, then you can use dir function to list all methods of this datatype

    代码
    >>> li
    []
    >>> dir(li)
    [
    '__add__', '__class__', '__contains__', '__delattr__', '__delitem__', '__delsli
    ce__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__getit
    em__
    ', '__getslice__', '__gt__', '__hash__', '__iadd__', '__imul__', '__init__',
    '__iter__', '__le__', '__len__', '__lt__', '__mul__', '__ne__', '__new__', '__r
    educe__', '__reduce_ex__', '__repr__', '__reversed__', '__rmul__', '__setattr__'
    , '__setitem__', '__setslice__', '__sizeof__', '__str__', '__subclasshook__', 'a
    ppend', 'count', 'extend', 'index', 'insert', 'pop', 'remove', 'reverse', 'sort'
    ]
    >>> d=[]
    >>> dir(d)
    [
    '__add__', '__class__', '__contains__', '__delattr__', '__delitem__', '__delsli
    ce__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__getit
    em__
    ', '__getslice__', '__gt__', '__hash__', '__iadd__', '__imul__', '__init__',
    '__iter__', '__le__', '__len__', '__lt__', '__mul__', '__ne__', '__new__', '__r
    educe__', '__reduce_ex__', '__repr__', '__reversed__', '__rmul__', '__setattr__'
    , '__setitem__', '__setslice__', '__sizeof__', '__str__', '__subclasshook__', 'a
    ppend', 'count', 'extend', 'index', 'insert', 'pop', 'remove', 'reverse', 'sort'
    ]

    Note:

         1)format: dir(variable), it is included by()

         2)the returned list contains the names of the methods as the datatype of variable.

    Work for fun,Live for love!
  • 相关阅读:
    初探动态规划(DP)
    高精度压位
    Poi写文件时报java.io.IOException: Read error
    mysql合并和时间函数
    线程池子线程先执行再执行主线程
    linux常用命令
    使用线程池应该注意的问题
    分页查询千万级数据慢
    待簳的题......
    记录脑残失误,让达摩克利斯之剑永远高悬
  • 原文地址:https://www.cnblogs.com/allenblogs/p/1806274.html
Copyright © 2011-2022 走看看