首页 > 编程语言 > 详细

输出python的help结果到文件中

时间:2017-05-27 15:04:25      阅读:383      评论:0      收藏:0      [点我收藏+]

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

 



输出python的help结果到文件中

原文:http://www.cnblogs.com/hushaojun/p/6912828.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!