我正在IPyton中运行一些代码::
jrlab@jrlab-T150s:~$ ipython
In [1]: from IPython import get_ipython
...: ipython = get_ipython()
...:
...: code = """
...: import matplotlib.pyplot as plt
...:
...: print("bla")
...:
...: plt.figure()
...: """
...: res = ipython.run_cell(code)
...:
bla
Out[1]: <Figure size 640x480 with 0 Axes>
如何禁用Out [1]打印,而不禁用 print 语句命令的打印?
答案 0 :(得分:1)
None
未打印为输出。因此,只需将; None
附加到您希望抑制其输出的任何行即可:
In [1]: 1+2
Out[1]: 3
In [2]: 1+2; None
In [3]: