python 将 help 输出的帮助信息写到文件

创建日期: 2023-08-08 16:25 | 作者: 风波 | 浏览次数: 14 | 分类: Python
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

import sys
output_help_to_file('abc.log', sys)

来源:https://stackoverflow.com/questions/11265603/how-do-i-export-the-output-of-pythons-built-in-help-function

14 浏览
6 爬虫
0 评论