Reading python documentation in the terminal?

后端 未结 6 788
谎友^
谎友^ 2020-12-30 12:14

Is there a way to install the python documentation that would make it available as if it was a manpage? (I know you can download the sourcefiles for the documentation and re

6条回答
  •  醉话见心
    2020-12-30 12:50

    You can use the BIF help()

    In terminal go to Python REPL like

    python
    

    Now type help()

    Now for example if you wish to get help for a class say IPv4Network which is in ipaddress package then you just have to specify the fully qualified path for IPv4Network i.e ipaddress.IPv4Network

    EXAMPLE:

    $ python3
    Python 3.6.5 |Anaconda, Inc.| (default, Apr 29 2018, 16:14:56) 
    [GCC 7.2.0] on linux
    Type "help", "copyright", "credits" or "license" for more information.
    >>> help()
    Welcome to Python 3.6's help utility!
    help> ipaddress.IPv4Network
    Help on class IPv4Network in ipaddress:
    
    ipaddress.IPv4Network = class IPv4Network(_BaseV4, _BaseNetwork)
     |  This class represents and manipulates 32-bit IPv4 network + addresses..
     |  
     |  Attributes: [examples for IPv4Network('192.0.2.0/27')]
     |      .network_address: IPv4Address('192.0.2.0')
     |      .hostmask: IPv4Address('0.0.0.31')
     |      .broadcast_address: IPv4Address('192.0.2.32')
     |      .netmask: IPv4Address('255.255.255.224')
     |      .prefixlen: 27
     |  
     |  Method resolution order:
     |      IPv4Network
     |      _BaseV4
     |      _BaseNetwork
     |      _IPAddressBase
     |      builtins.object
     |  
     |  Methods defined here:
     |  
     |  __init__(self, address, strict=True)
     |      Instantiate a new IPv4 network object.
     |      
     |      Args:
     |          address: A string or integer representing the IP [& network].
     |            '192.0.2.0/24'
     |            '192.0.2.0/255.255.255.0'
     |            '192.0.0.2/0.0.0.255'
     |            are all functionally the same in IPv4. Similarly,
     |            '192.0.2.1'
    

    and so on

提交回复
热议问题