Python内置函数dir详解

1158次阅读  |  发布于5年以前

1.命令介绍

最近学习并使用了一个python的内置函数dir,首先help一下:

复制代码 代码如下:

help(dir)
Help on built-in function dir in module builtin:

dir()
dir([object]) -> list of strings

Return an alphabetized list of names comprising (some of) the attributes  
of the given object, and of attributes reachable from it:


No argument:  the names in the current scope.  
Module object:  the module attributes.  
Type or class object:  its attributes, and recursively the attributes of  
    its bases.  
Otherwise:  its attributes, its class's attributes, and recursively the  
    attributes of its class's base classes.

Copyright© 2013-2020

All Rights Reserved 京ICP备2023019179号-8