創(chuàng)新互聯(lián)www.cdcxhl.cn八線動態(tài)BGP香港云服務(wù)器提供商,新人活動買多久送多久,劃算不套路!
創(chuàng)新互聯(lián)2013年開創(chuàng)至今,是專業(yè)互聯(lián)網(wǎng)技術(shù)服務(wù)公司,擁有項目成都網(wǎng)站設(shè)計、成都網(wǎng)站制作、外貿(mào)網(wǎng)站建設(shè)網(wǎng)站策劃,項目實施與項目整合能力。我們以讓每一個夢想脫穎而出為使命,1280元梨樹做網(wǎng)站,已為上家服務(wù),為梨樹各地企業(yè)和個人服務(wù),聯(lián)系電話:13518219792這篇文章將為大家詳細講解有關(guān)python中help函數(shù)的使用方式是什么,小編覺得挺實用的,因此分享給大家做個參考,希望大家閱讀完這篇文章后可以有所收獲。
python內(nèi)置了很多內(nèi)置函數(shù)、類方法屬性及各種模塊。當(dāng)我們想要當(dāng)我們想要了解某種類型有哪些屬性方法以及每種方法該怎么使用時,我們可以使用dir()函數(shù)和help()函數(shù)在python ide交互式模式下獲得我們想要的信息。
dir()
dir()用來查詢一個類或者對象所有屬性,比如:
>>> dir(list) ['__add__', '__class__', '__contains__', '__delattr__', '__delitem__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__getitem__', '__gt__', '__hash__', '__iadd__', '__imul__', '__init__', '__iter__', '__le__', '__len__', '__lt__', '__mul__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__reversed__', '__rmul__', '__setattr__', '__setitem__', '__sizeof__', '__str__', '__subclasshook__', 'append',
help()
help()函數(shù)幫助我們了解模塊、類型、對象、方法、屬性的詳細信息,幫助查看類型詳細信息,包含類的創(chuàng)建方式、屬性、方法。
>>> help(list) Help on class list in module builtins: class list(object) | list() -> new empty list | list(iterable) -> new list initialized from iterable's items | | Methods defined here: | | __add__(self, value, /) | Return self+value. | | __contains__(self, key, /) | Return key in self. | | __delitem__(self, key, /) | Delete self[key]. | | __eq__(self, value, /) | Return self==value. | | __ge__(self, value, /) | Return self>=value. | | __getattribute__(self, name, /) | Return getattr(self, name). | | __getitem__(...) | x.__getitem__(y) <==> x[y] | | __gt__(self, value, /) | Return self>value. | | __iadd__(self, value, /) | Implement self+=value. | | __imul__(self, value, /) | Implement self*=value. | | __init__(self, /, *args, **kwargs) -- More --
舉例如下:
查看python所有的關(guān)鍵字:help("keywords")
查看python所有的modules:help("modules")
單看python所有的modules中包含指定字符串的modules: help("modules yourstr")
查看python中常見的topics: help("topics")
查看python標(biāo)準(zhǔn)庫中的module:import os.path + help("os.path")
查看python內(nèi)置的類型:help("list")
查看python類型的成員方法:help("str.find")
查看python內(nèi)置函數(shù):help("open")
關(guān)于python中help函數(shù)的使用方式是什么就分享到這里了,希望以上內(nèi)容可以對大家有一定的幫助,可以學(xué)到更多知識。如果覺得文章不錯,可以把它分享出去讓更多的人看到。
分享標(biāo)題:python中help函數(shù)的使用方式是什么-創(chuàng)新互聯(lián)
文章起源:http://muchs.cn/article0/hspio.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供移動網(wǎng)站建設(shè)、全網(wǎng)營銷推廣、建站公司、小程序開發(fā)、商城網(wǎng)站、營銷型網(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)
猜你還喜歡下面的內(nèi)容