如何輸出到stdout
被壓制?如何在IPython Notebook中抑制輸出?
分號可用於剿返回的對象的顯示,例如
>>> 1+1
2
>>> 1+1; # No output!
然而,打印到標準輸出的功能不受分號。
>>> print('Hello!')
Hello!
>>> MyFunction()
Calculating values...
如何從print
/MyFunction
輸出被抑制?
如何輸出到stdout
被壓制?如何在IPython Notebook中抑制輸出?
分號可用於剿返回的對象的顯示,例如
>>> 1+1
2
>>> 1+1; # No output!
然而,打印到標準輸出的功能不受分號。
>>> print('Hello!')
Hello!
>>> MyFunction()
Calculating values...
如何從print
/MyFunction
輸出被抑制?
將%%capture
添加爲單元格的第一行。例如
%%capture
print('Hello')
MyFunction()
這簡單地丟棄的輸出,但%%capture
魔可用於將輸出保存到變量 - consult the docs
任何人都知道%% capture的相反情況是什麼?如在中,你如何在一個單元格內停止%%捕獲,或者直到單元格結束時才啓用它? –
要知道'%% capture'只有在單元格結束之前才能啓用,並且它必須出現在單元格中的任何代碼之前。 (所以看起來沒有辦法在細胞內捕獲。) – Arel
將一個;
在一行結束時抑制輸出的打印[Reference]。
iruby內核只需添加'nil'作爲最後一行 – frenesim