国产成人精品亚洲777人妖,欧美日韩精品一区视频,最新亚洲国产,国产乱码精品一区二区亚洲

您的位置:首頁(yè)技術(shù)文章
文章詳情頁(yè)

python的help函數(shù)如何使用

瀏覽:138日期:2022-07-21 15:21:28

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)編寫(xiě)代碼時(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)填寫(xiě)參數(shù),操作方法很簡(jiǎn)單。

使用help函數(shù)查看幫助時(shí)需要注意哪些問(wèn)題

在寫(xiě)help()函數(shù)使用方法時(shí)說(shuō)過(guò),括號(hào)中填寫(xiě)參數(shù),那在這里要注意參數(shù)的形式:

1、查看一個(gè)模塊的幫助

>>>help(’sys’)

之后它回打開(kāi)這個(gè)模塊的幫助文檔

2、查看一個(gè)數(shù)據(jù)類型的幫助

>>>help(’str’)

返回字符串的方法及詳細(xì)說(shuō)明

>>>a = [1,2,3]>>>help(a)

這時(shí)help(a)則會(huì)打開(kāi)list的操作方法

>>>help(a.append)

會(huì)顯示list的append方法的幫助。

實(shí)例擴(kuò)展:

怎么使用help函數(shù)查看python模塊中函數(shù)的用法

help()括號(hào)內(nèi)填寫(xiě)參數(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 attributes 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.

到此這篇關(guān)于python的help函數(shù)如何使用的文章就介紹到這了,更多相關(guān)如何使用python的help函數(shù)內(nèi)容請(qǐng)搜索好吧啦網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持好吧啦網(wǎng)!

標(biāo)簽: Python 編程
相關(guān)文章:
主站蜘蛛池模板: 青海省| 顺平县| 沧源| 南汇区| 拜泉县| 延寿县| 海晏县| 金坛市| 布拖县| 金乡县| 巩留县| 石景山区| 云龙县| 苍梧县| 龙口市| 益阳市| 长顺县| 钟山县| 奉新县| 阿巴嘎旗| 阜平县| 雷山县| 尤溪县| 静宁县| 江永县| 林周县| 太湖县| 大埔县| 新宾| 安徽省| 柳江县| 太湖县| 苏尼特右旗| 班戈县| 安阳县| 达孜县| 富阳市| 遂川县| 余庆县| 凤山市| 商城县|