How do I export the output of Python's built-in help() function

前端 未结 9 1069
时光取名叫无心
时光取名叫无心 2020-12-15 20:19

I\'ve got a python package which outputs considerable help text from: help(package)

I would like to export this help text to a file, in the format in w

9条回答
  •  自闭症患者
    2020-12-15 20:39

    To get a "clean" text output, just as the built-in help() would deliver, and suitable for exporting to a file or anything else, you can use the following:

    >>> import pydoc
    >>> pydoc.render_doc(len, renderer=pydoc.plaintext)
    'Python Library Documentation: built-in function len in module builtins\n\nlen(obj, /)\n    Return the number of items in a container.\n'
    

提交回复
热议问题