Home >Backend Development >Python Tutorial >What does dir mean in python?
What does dir mean in python?
When the dir() function in python takes no parameters, it returns the current List of variables, methods and defined types within the scope; when parameters are taken, a list of properties and methods of the parameters is returned. If the argument contains the method __dir__(), this method will be called. If the parameter does not contain __dir__(), this method will collect parameter information to the maximum extent possible.
dir Syntax:
dir([object])
Parameter description:
object -- object, variable, type.
Return value
Returns the attribute list of the module.
The following example shows how to use dir:
>>>dir() # 获得当前模块的属性列表 ['__builtins__', '__doc__', '__name__', '__package__', 'arr', 'myslice'] >>> dir([ ]) # 查看列表的方法 ['__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'] >>>
Related recommendations: "Python Tutorial"
The above is the detailed content of What does dir mean in python?. For more information, please follow other related articles on the PHP Chinese website!