I am using the pydoc.render_doc() to print help for a module, however it outputs a field labeled "DATA" which I don't wish to print. Is there any way to ommit that?

Here is an example of what it prints:

DATA
absolute_import = _Feature((2, 5, 0, 'alpha', 1), (2, 7, 0, 'alpha', 0...
有帮助吗?

解决方案

Based on my reading of the PyDoc module source code there is no way to disable the printing of the bigsection headers.

Your best bet is to strip the DATA from the output before it is sent off to be consumed.

data = "D\x08DA\x08AT\x08TA\x08A\n" #  DATA bigsection header from pydoc
pydoc.render_doc(module).replace(data, '')

There are backspaces(\x08) in the bigsection header. This is explained here.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top