How to search help using python console

前端 未结 10 1305
长发绾君心
长发绾君心 2021-02-08 20:25

Is there any way to search for a particular package/function using keywords in the Python console?

For example, I may want to search \"pdf\" for pdf related tasks.

10条回答
  •  [愿得一人]
    2021-02-08 20:44

    Try help() or dir(). AFAIR there's no builtin support for pdf-related tasks in plain Python installation. Another way to find help for Python modules is to google ;)

    Docs:

    http://docs.python.org/library/functions.html#help

    http://docs.python.org/library/functions.html#dir

    EDIT:

    >>> import os
    >>> def search_help(keyword):
    ...     os.system('python Lib/pydoc.py -k %s' % keyword)
    ...
    >>> search_help('math')
    cmath - This module is always available. It provides access to mathematical
    math - This module is always available.  It provides access to the
    test.test_cmath
    test.test_math
    >>> search_help('pdf')
    >>> _
    

    You have to have main python dir in your path. And it won't work under IDLE. HTH.

提交回复
热议问题