command-line - 抑制 *Out[]* IPython 打印,但不抑制其他打印
问题描述
我在 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语句命令的打印?
解决方案
None
不作为输出打印。因此,只需附加; None
到您希望抑制其输出的任何行:
In [1]: 1+2
Out[1]: 3
In [2]: 1+2; None
In [3]:
推荐阅读
- c++ - 将静态库与 -nostdlib 链接时出现“对 __dso_handle 的未定义引用”
- php - 如何在PHP中自动插入可编辑数据表
- arrays - 关于行的“正值岛”中元素的位置
- typescript - 如何在 Typescript 中定义递归字符串文字类型
- android - Android Kotlin NavigationView 将角半径添加到项目图标
- vb.net - 无论如何我可以用电报机器人更改 textbox1.text 值吗?
- python - 错误:无法确定关系的真值
- java - 在创建从 T 类型展开的链表中创建二维数组的方法时遇到问题
- vhdl - 更改输入后,sha256 代码的输出保持不变
- android - 如何在jetpack compose中正确使用自定义AlertDialog?