我有一个python包,它输出了相当多的帮助文本:help(package)
我想以help(package)显示的格式将此帮助文本导出到文件中
我该怎么做呢?
发布于 2012-06-30 01:05:38
这有点老生常谈(而且可能有更好的解决方案),但这是有效的:
import sys
import pydoc
def output_help_to_file(filepath, request):
f = open(filepath, 'w')
sys.stdout = f
pydoc.help(request)
f.close()
sys.stdout = sys.__stdout__
return然后..。
>>> output_help_to_file(r'test.txt', 're')https://stackoverflow.com/questions/11265603
复制相似问题