python的help函式如何使用

2022-10-04 14:15:42 字數 1594 閱讀 6429

help函式是python的乙個內建函式,在python基礎知識中介紹過什麼是內建函式,它是python自帶的函式,任何時候都可以被使。help函式能作什麼、怎麼使用help函式檢視python模組學習中函式的用法,和使用help函式時需要注意哪些問題,下面來簡單的說一下。

help函式能作什麼

在使用python來編寫**時,會經常使用python呼叫函式、自帶函式或模組,一些不常用的函式或是模組的用途不是很清楚,這時候就需要用到help函式來檢視幫助。

這裡要注意下,help()函式是檢視函式或模組用途的詳細說明,而dir()函式是檢視函式或模組內的操作方法都有什麼,輸出的是方法列表。

怎麼使用help函式檢視python模組中函式的用法

help( )括號內填寫引數,操作方法很簡單。

使用help函式檢視幫助時需要注意哪些問題

在寫help()函式使用方法時說過,括號中填寫引數,那在這裡要注意引數的形式:

1、檢視乙個模組的幫助程式設計客棧

>>>help('sys')

之後它回開啟這個模組的幫助文件

2、檢視乙個資料型別的幫助

>>>help('str')

返回字串的方法及詳細說明

>>>a = [1,2,3]

>>>help(a)

這時help(a)則會開啟list的操作方法

>>>help(a.append)

會顯示list的append方法的幫助。

例項擴充套件:

怎麼使用help函式檢視python模組中函式的用法

help()括號內填寫引數,操作方法很簡單。例如:

>>> 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() log 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

rec程式設計客棧ursively the attributes of its class's base classes.

python的help函式如何使用

python的help函式如何使用 help函式是python的乙個內建函式,在python基礎知識中介紹過什麼是內建函式,它是python自帶的函式,任何時候都可以被使。help函式能作什麼 怎麼使用help函式檢視python模組學習中函式的用法,和使用help函式時需要注意哪些問題,下面來簡單...

python的help函式如何使用

help函式是python的乙個內建函式,在python基礎知識中介紹過什麼是內建函式,它是python自帶的函式,任何時候都可以被使。help函式能作什麼 怎麼使用help函式檢視python模組學習中函式的用法,和使用help函式時需要注意哪些問題,下面來簡單的說一下。help函式能作什麼 在使...

python的help函式如何使用

help函式是python的乙個內建函式,在python基礎知識中介紹過什麼是內建函式,它是python自帶的函式,任何時候都可以被使。help函式能作什麼 怎麼使用help函式檢視python模組學習中函式的用法,和使用help函式時需要注意哪些問題,下面來簡單的說一下。help函式能作什麼 在使...