新聞中心
這里有您想知道的互聯(lián)網(wǎng)營銷解決方案
創(chuàng)新互聯(lián)Python教程:python中dir是什么
DIR() 函數(shù)不帶參數(shù)時(shí),返回當(dāng)前范圍內(nèi)的變量、方法和定義的類型列表;帶參數(shù)時(shí),返回參數(shù)的屬性、方法列表。如果參數(shù)包含方法__dir__(),該方法將被調(diào)用。如果參數(shù)不包含__dir__(),該方法將限度地收集參數(shù)信息。

dir 語法:
dir([object])
參數(shù)說明
object -- 對象、變量、類型。
返回值
返回模塊的屬性列表。
Python學(xué)習(xí)網(wǎng)- 專業(yè)的python自學(xué)、交流公益平臺(tái)!
以下實(shí)例展示了 dir 的使用方法:
>>>dir() # 獲得當(dāng)前模塊的屬性列表 ['__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'] >>>
本文題目:創(chuàng)新互聯(lián)Python教程:python中dir是什么
轉(zhuǎn)載注明:http://m.fisionsoft.com.cn/article/coghjcj.html


咨詢
建站咨詢
