欧美一区二区三区老妇人-欧美做爰猛烈大尺度电-99久久夜色精品国产亚洲a-亚洲福利视频一区二区

python中dir()函數(shù)怎么用-創(chuàng)新互聯(lián)

創(chuàng)新互聯(lián)www.cdcxhl.cn八線動態(tài)BGP香港云服務(wù)器提供商,新人活動買多久送多久,劃算不套路!

專業(yè)從事成都網(wǎng)站制作、成都網(wǎng)站建設(shè),高端網(wǎng)站制作設(shè)計,微信小程序,網(wǎng)站推廣的成都做網(wǎng)站的公司。優(yōu)秀技術(shù)團隊竭力真誠服務(wù),采用H5建站+CSS3前端渲染技術(shù),成都響應式網(wǎng)站建設(shè)公司,讓網(wǎng)站在手機、平板、PC、微信下都能呈現(xiàn)。建站過程建立專項小組,與您實時在線互動,隨時提供解決方案,暢聊想法和感受。

python中dir()函數(shù)怎么用?很多新手對此不是很清楚,為了幫助大家解決這個難題,下面小編將為大家詳細講解,有這方面需求的人可以來學習下,希望你能有所收獲。

今天我們來看一個非常重要的函數(shù):dir()

中文說明:不帶參數(shù)時,返回當前范圍內(nèi)的變量、方法和定義的類型列表;帶參數(shù)時,返回參數(shù)的屬性、方法列表。如果參數(shù)包含方法__dir__(),該方法將被調(diào)用。如果參數(shù)不包含__dir__(),該方法將大限度地收集參數(shù)信息。

參數(shù)object: 對象、變量、類型。

版本:該函數(shù)在python各個版本中都有,但是每個版本中顯示的屬性細節(jié)有所不同。使用時注意區(qū)別。

英文說明:

dir([object])

Without arguments, return the list of names in the current local scope. With an argument, attempt to return a list of
 valid attributes for that object.

If the object has a method named __dir__(), this method will be called and must return the list of attributes. This
 allows objects that implement a custom __getattr__() or __getattribute__() function to customize the way dir()
  reports their attributes.

If the object does not provide __dir__(), the function tries its best to gather information from the object’
s __dict__ attribute, if defined, and from its type object. The resulting list is not necessarily complete, and may be
 inaccurate when the object has a custom __getattr__().

The default dir() mechanism behaves differently with different types of objects, as it attempts to produce the most 
relevant, rather than complete, information:

If the object is a module object, the list contains the names of the module’s attributes.

If the object is a type or class object, the list contains the names of its attributes, and recursively of the 
attributes of its bases.

Otherwise, the list contains the object’s attributes’ names, the names of its class’s attributes, and recursively
 of the attributes of its class’s base classes.

例如

>>>import struct
>>>dir()  # show the names in the module namespace
['__builtins__','__doc__','__name__','struct']
>>>dir(struct)  # show the names in the struct module
['Struct','__builtins__','__doc__','__file__','__name__',
 '__package__','_clearcache','calcsize','error','pack','pack_into',
 'unpack','unpack_from']
>>>class Shape(object):
        def __dir__(self):
            return ['area','perimeter','location']
>>> s= Shape()
>>>dir(s)
['area', 'perimeter', 'location']
Note Because dir() is supplied primarily as a convenience for use at an interactive prompt, it tries to supply an 
interesting set of names more than it tries to supply a rigorously or consistently defined set of names, and its 
detailed behavior may change across releases. For example, metaclass attributes are not in the result list when the 
argument is a class.

代碼實例

>>>dir()
['__builtins__','__doc__','__name__','__package__']
>>>import struct
>>>dir()
['__builtins__','__doc__','__name__','__package__','struct']
>>>dir(struct)
['Struct','__builtins__','__doc__','__file__','__name__','__package__','_clearcache','calcsize','error','pack',
'pack_into','unpack','unpack_from']
>>>class Person(object):
...    def __dir__(self):
...            return ["name","age","country"]
...
>>>dir(Person)
['__class__','__delattr__','__dict__','__dir__','__doc__','__format__','__getattribute__','__hash__','__init__',
'__module__','__new__','__reduce__','__reduce_ex__','__repr__','__setattr__','__sizeof__','__str__','__subclasshook__',
'__weakref__']
>>> tom= Person()
>>>dir(tom)
['age','country','name']

看完上述內(nèi)容是否對您有幫助呢?如果還想對相關(guān)知識有進一步的了解或閱讀更多相關(guān)文章,請關(guān)注創(chuàng)新互聯(lián)-成都網(wǎng)站建設(shè)公司行業(yè)資訊頻道,感謝您對創(chuàng)新互聯(lián)的支持。

文章標題:python中dir()函數(shù)怎么用-創(chuàng)新互聯(lián)
文章出自:http://chinadenli.net/article22/djjicc.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供關(guān)鍵詞優(yōu)化搜索引擎優(yōu)化品牌網(wǎng)站建設(shè)、網(wǎng)站營銷外貿(mào)建站、品牌網(wǎng)站設(shè)計

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)

手機網(wǎng)站建設(shè)
国产精品免费无遮挡不卡视频| 午夜福利92在线观看| 国产一级不卡视频在线观看| 中字幕一区二区三区久久蜜桃| 欧美亚洲三级视频在线观看| 国产又猛又黄又粗又爽无遮挡| 好吊妞视频这里有精品| 国产精品白丝久久av| 精品国产亚洲av久一区二区三区| 欧美人妻一区二区三区| 大香蕉再在线大香蕉再在线| 国产精品乱子伦一区二区三区| 久久热九九这里只有精品| 亚洲欧美日韩熟女第一页| 国产偷拍盗摄一区二区| 中文字幕一区二区熟女| 91人妻丝袜一区二区三区| 一个人的久久精彩视频| 国产成人精品视频一区二区三区| 欧美胖熟妇一区二区三区| 日韩人妻欧美一区二区久久| 少妇熟女亚洲色图av天堂| 黄色在线免费高清观看| 国产一区二区三区av在线| 一区二区三区日韩经典| 日本三区不卡高清更新二区| 91老熟妇嗷嗷叫太91| 国产一区二区三区口爆在线| 日本少妇中文字幕不卡视频| 五月婷婷缴情七月丁香| 国产成人精品在线播放| 国产又粗又猛又大爽又黄同志| 熟女少妇久久一区二区三区| 亚洲高清中文字幕一区二三区| 丰满的人妻一区二区三区| 青草草在线视频免费视频| 白丝美女被插入视频在线观看| 国内女人精品一区二区三区| 国产精品一区欧美二区| 精品推荐国产麻豆剧传媒| 久久永久免费一区二区|