pythondir是什么
python中dir()函数不带参数时,返回当前范围内的变量、方法和定义的类型列表;带参数时,返回参数的属性、方法列表。如果参数包含方法__dir__(),该方法将被调用。如果参数不包含__dir__(),该方法将限度地收集参数信息。
dir语法:
dir([object])
参数说明
object--对象、变量、类型。
返回值
返回模块的属性列表。
以下实例展示了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']
>>>
以上内容为大家介绍了python培训之dir是什么,希望对大家有所帮助,如果想要了解更多Python相关知识,请关注IT培训机构:千锋教育。

相关推荐HOT
更多>>
python代码中编译是什么
python代码中编译是什么说明1、在执行Python代码时,在Python解释器用四个过程“拆解”我们的代码,最终被CPU执行返回给用户。2、当用户键入代...详情>>
2023-11-10 22:50:25
pythonconfusion_matrix()是什么
pythonconfusion_matrix()是什么说明1、计算分类器预测结果的混淆矩阵C。2、混淆矩阵C使得C_ij等于已知在第i组中并且预计在第j组中的观测次数。...详情>>
2023-11-10 20:26:14
pythonos.system执行cmd指令
pythonos.system执行cmd指令1、执行cmd指令,在cmd输出的内容会直接在控制台输出,返回结果为0表示执行成功。2、在调用完shell脚本后,返回一个...详情>>
2023-11-10 19:52:30
pythonTKinter的绑定方法
python中TKinter的绑定方法1、bind_all全局绑定,默认是全局快捷键,比如F1是帮助文档。2、bind_class接受三个参数,第一个是类名,第二个是事...详情>>
2023-11-10 18:47:02