调试时,我经常掉入IPython Shell进行交互式代码测试。但是,这也会导致python版本,日期和帮助说明的大量信息转储到stdout。如何抑制此信息,以免掩盖故意的调试消息?
x = get_important_data()
print 'important info! right here! The data is in variable "x"'
import IPython
IPython.embed()
Run Code Online (Sandbox Code Playgroud)
这段代码给出了这样的输出...
important info! right here! The data is in variable "x"
Python 2.7.11 |Anaconda 2.4.0 (x86_64)| (default, Dec 6 2015, 18:57:58)
Type "copyright", "credits" or "license" for more information.
IPython 4.0.0 -- An enhanced Interactive Python.
? -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help -> Python's own help system.
object? -> Details about 'object', use 'object??' …Run Code Online (Sandbox Code Playgroud)