输出python的help结果到文件中

1.命令行方式:

1 python -c "import sys; help(sys.exit)" > help.txt

2.函数代码的方式输出
 1 def help_output(help_element):
 2     filename = 'help.txt'
 3 
 4     stdout = sys.stdout
 5     out_file = open(filename, 'w+')
 6     sys.stdout = out_file
 7 
 8     help(help_element)
 9     out_file.flush()
10 
11     out_file.close()
12     sys.stdout = stdout


原文地址:https://www.cnblogs.com/hushaojun/p/6912828.html