創(chuàng)新互聯(lián)www.cdcxhl.cn八線動(dòng)態(tài)BGP香港云服務(wù)器提供商,新人活動(dòng)買多久送多久,劃算不套路!
本篇文章給大家分享的是有關(guān)Python中的help函數(shù)的使用方法,小編覺(jué)得挺實(shí)用的,因此分享給大家學(xué)習(xí),希望大家閱讀完這篇文章后可以有所收獲,話不多說(shuō),跟著小編一起來(lái)看看吧。
help函數(shù)是python的一個(gè)內(nèi)置函數(shù),在python基礎(chǔ)知識(shí)中介紹過(guò)什么是內(nèi)置函數(shù),它是python自帶的函數(shù),任何時(shí)候都可以被使。help函數(shù)能作什么、怎么使用help函數(shù)查看python模塊學(xué)習(xí)中函數(shù)的用法,和使用help函數(shù)時(shí)需要注意哪些問(wèn)題,下面來(lái)簡(jiǎn)單的說(shuō)一下。
help函數(shù)能作什么
在使用python來(lái)編寫代碼時(shí),會(huì)經(jīng)常使用python調(diào)用函數(shù)、自帶函數(shù)或模塊,一些不常用的函數(shù)或是模塊的用途不是很清楚,這時(shí)候就需要用到help函數(shù)來(lái)查看幫助。
這里要注意下,help()函數(shù)是查看函數(shù)或模塊用途的詳細(xì)說(shuō)明,而dir()函數(shù)是查看函數(shù)或模塊內(nèi)的操作方法都有什么,輸出的是方法列表。
怎么使用help函數(shù)查看python模塊中函數(shù)的用法
help( )括號(hào)內(nèi)填寫參數(shù),操作方法很簡(jiǎn)單。
使用help函數(shù)查看幫助時(shí)需要注意哪些問(wèn)題
在寫help()函數(shù)使用方法時(shí)說(shuō)過(guò),括號(hào)中填寫參數(shù),那在這里要注意參數(shù)的形式:
1、查看一個(gè)模塊的幫助
>>>help('sys')
之后它回打開這個(gè)模塊的幫助文檔
2、查看一個(gè)數(shù)據(jù)類型的幫助
>>>help('str')
返回字符串的方法及詳細(xì)說(shuō)明
>>>a = [1,2,3] >>>help(a)
這時(shí)help(a)則會(huì)打開list的操作方法
>>>help(a.append)
會(huì)顯示list的append方法的幫助。
實(shí)例擴(kuò)展:
怎么使用help函數(shù)查看python模塊中函數(shù)的用法
help()括號(hào)內(nèi)填寫參數(shù),操作方法很簡(jiǎn)單。例如:
>>> help('dir') Help on built-in function dir in module builtins: dir(...) dir([object]) -> list of strings If called without an argument, return the names in the current scope. Else, return an alphabetized list of names comprising (some of) the attribut es of the given object, and of attributes reachable from it. If the object supplies a method named __dir__, it will be used; otherwise the default dir() logic is used and returns: for a module object: the module's attributes. for a class object: its attributes, and recursively the attributes of its bases. for any other object: its attributes, its class's attributes, and recursively the attributes of its class's base classes.
以上就是Python中的help函數(shù)的使用方法,小編相信有部分知識(shí)點(diǎn)可能是我們?nèi)粘9ぷ鲿?huì)見到或用到的。希望你能通過(guò)這篇文章學(xué)到更多知識(shí)。更多詳情敬請(qǐng)關(guān)注創(chuàng)新互聯(lián)-成都網(wǎng)站建設(shè)公司行業(yè)資訊頻道。
網(wǎng)站題目:Python中的help函數(shù)怎么用-創(chuàng)新互聯(lián)
URL分享:http://www.chinadenli.net/article18/cogogp.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供自適應(yīng)網(wǎng)站、建站公司、軟件開發(fā)、定制網(wǎng)站、做網(wǎng)站、動(dòng)態(tài)網(wǎng)站
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)
猜你還喜歡下面的內(nèi)容