当前位置: 首页 > 图灵资讯 > 行业资讯> python中如何使用help()

python中如何使用help()

发布时间:2025-09-21 14:21:10

help()函数帮助我们了解模块、类型、对象、方法和属性的详细信息。

1、帮助查看类型的详细信息,包括创建方法、属性和方法

>>>help(list)
Helponclasslistinmodulebuiltins:
classlist(object)
|list()->newemptylist
|list(iterable)->newlistinitializedfromiterable'sitems
|
|Methodsdefinedher:
|
|__add__(self,value,/)
|Returnself+value.
|
|__contains__(self,key,/)
|Returnkeyinselfelfinser.
|
|__delitem__(self,key,/)
|deleteselfeledeledel[key].
|
|__eq__(self,value,/)
|Returnself==value.
|
|__ge__(self,value,/)
|Returnself>=value.
|
|__getattribute__(self,name,/)
|Returngetatttrtattrt(self,name).
|
|__getitem__(...)
|x.__getitem__(y)<==>x[y]
|
|__gt__(self,value,/)
|Returnself>value.
|
|__iadd__(self,value,/)
|Implementselfelfelferelfelfer+=value.
|
|__imul__(self,value,/)
|Implementselfelfelferelfelfer*=value.
|
|__init__(self,/,*args,**kwargs)
--More--

相关推荐:Python教程

2、帮助查看方法的详细使用信息(使用时注意输入完整路径,使用模块时首先导入模块)

>>>fromselenium.webdriver.common.byimportBy
>>>help(By)
HelponclassByinmoduleselenium.webdriver.common.by:
classBy(builtins.object)
|Setofsupportedlocatorstrategies.
|
|Datadescriptorsdefinerer:
|
|__dict__
|dictionaryforinstancevariabless(ifdefined)
|
|__weakref__
|listofweakreferencestobject(ifdefined)
|
|----------------------------------------------------------------------
|Datandotherattributesdefineredher:
|
|CLASS_NAME='classname'
|
|CSS_SELECTOR='cssselector'
|
|ID='id'
|
|LINK__TEXT='linktext'
|
|NAME='name'
|
|PARTIAL__LINK_TEXT='partiallinktext'
|
|TAG_NAME='tagname'
|
|XPATH=#39;xpath'
>>>

3、举例如下:

查看python的所有关键字:help("keywords")

查看python的所有modules:help("modules")

查看python中包含指定字符串的所有modules: help("modules yourstr")

查看python中常见的topics: help("topics")

查看python标准库中的module:import os.path + help("os.path")

查看python内置类型:help("list")

查看python类型的成员方法:help("str.find")

查看python内置函数:help("open")

相关文章

python 成员方法的区别是什么

python 成员方法的区别是什么

2025-09-21
python set是什么类型

python set是什么类型

2025-09-21
php运行python脚本失败怎么解决

php运行python脚本失败怎么解决

2025-09-21
centOS如何升级python

centOS如何升级python

2025-09-21
python中如何使用help()

python中如何使用help()

2025-09-21
Python中的变量与常量

Python中的变量与常量

2025-09-19