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

前端 未结 9 1041
时光取名叫无心
时光取名叫无心 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:40

    pydoc.render_doc(thing) to get thing's help text as a string. Other parts of pydoc like pydoc.text and pydoc.html can help you write it to a file.

    Using the -w modifier in linux will write the output to a html in the current directory, for example;

    pydoc -w Rpi.GPIO
    

    Puts all the help() text that would be presented from the command help(Rpi.GPIO) into a nicely formatted file Rpi.GPIO.html, in the current directory of the shell

提交回复
热议问题