小白教程
所有教程
关于
Search
172.70.131.102
172.70.131.102
参数设置
贡献
退出
操作
编辑
移动
保护
信息
历史
删除
查看“Python func dir”的源代码
本页内容
上一节:
Python_func_all
下一节:
Python3_func_hex
因为以下原因,您没有权限编辑本页:
您请求的操作仅限属于该用户组的用户执行:
用户
您可以查看和复制此页面的源代码。
{{DISPLAYTITLE:dir()}}[[Category:python3 built in functions|7]] = Python dir() 函数 = [[python built in functions|Python 内置函数]] == 描述 == '''dir()''' 函数不带参数时,返回当前范围内的变量、方法和定义的类型列表;带参数时,返回参数的属性、方法列表。如果参数包含方法__dir__(),该方法将被调用。如果参数不包含__dir__(),该方法将最大限度地收集参数信息。 == 语法 == dir 语法: <sample title="" desc="" lang="python" hererun="1"> dir([object]) </sample> 参数说明: * object -- 对象、变量、类型。 == 返回值 == 返回模块的属性列表。 以下实例展示了 dir 的使用方法: <sample title="" desc="" lang="python" hererun="1"> >>>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'] >>> </sample> [[python built in functions|Python 内置函数]]
返回至“
Python func dir
”。
上一节:
Python_func_all
下一节:
Python3_func_hex