成都网站建设设计

将想法与焦点和您一起共享

python中使用help()的方法-创新互联

创新互联www.cdcxhl.cn八线动态BGP香港云服务器提供商,新人活动买多久送多久,划算不套路!

成都创新互联公司始终坚持【策划先行,效果至上】的经营理念,通过多达十余年累计超上千家客户的网站建设总结了一套系统有效的全网营销解决方案,现已广泛运用于各行各业的客户,其中包括:成都茶艺设计等企业,备受客户好评。

小编给大家分享一下python中使用help()的方法,相信大部分人都还不怎么了解,因此分享这篇文章给大家参考一下,希望大家阅读完这篇文章后大有收获,下面让我们一起去了解一下吧!

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

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

>>> 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  --

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

>>> from selenium.webdriver.common.by import By
>>> help(By)
Help on class By in module selenium.webdriver.common.by:
class By(builtins.object)
 |  Set of supported locator strategies.
 |
 |  Data descriptors defined here:
 |
 |  __dict__
 |      dictionary for instance variables (if defined)
 |
 |  __weakref__
 |      list of weak references to the object (if defined)
 |
 |  ----------------------------------------------------------------------
 |  Data and other attributes defined here:
 |
 |  CLASS_NAME = 'class name'
 |
 |  CSS_SELECTOR = 'css selector'
 |
 |  ID = 'id'
 |
 |  LINK_TEXT = 'link text'
 |
 |  NAME = 'name'
 |
 |  PARTIAL_LINK_TEXT = 'partial link text'
 |
 |  TAG_NAME = 'tag name'
 |
 |  XPATH = 'xpath'
>>>

3、举例如下:

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

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

查看python所有的modules中包含指定字符串的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中使用help()的方法的所有内容,感谢各位的阅读!相信大家都有了一定的了解,希望分享的内容对大家有所帮助,如果还想学习更多知识,欢迎关注创新互联-成都网站建设公司行业资讯频道!


网站栏目:python中使用help()的方法-创新互联
分享地址:http://chengdu.cdxwcx.cn/article/eegcj.html