问题描述
在linux终端中,当一个命令的输出太长而无法在一个页面中读取时,我可以这样做:
In linux terminal, when the output of one command is too long to read in one page, i can do this:
cat file | less
这样我就可以读取并向上和向下滚动cat file的输出
so that i can read and scroll up and down the output from "cat file"
我如何在ipython中执行此操作?
how can i do this in ipython ?
例如:
i尝试了这个并且它没有工作:
for example:i tried this and it didnt work:
whos | less
我原来的问题是,通过Shift +页面来看,whos的输出太多了我不想改变滚动缓冲区
my original problem is that the output from whos is too much to be seen by doing Shift+page up and i dont want to change the scroll buffer
谢谢
推荐答案
在IPython中,您可以使用%page obj
使用标准寻呼机显示对象 obj
(通常为少
)。或者,您可以增加终端的滚动缓冲区,这在任何情况下都可能很方便。
In IPython, you can use %page obj
to show the object obj
using your standard pager (usually less
). Alternatively, you can increase the scroll buffer of your terminal, which might be convenient in any case.
%page obj
- 显示对象类似于IPython默认显示(类似repr),如果输出大小需要使用寻呼机
%page obj
-- display object similar to IPython default display (repr-like), using pager if output size requires
%page -r obj
- 显示与打印类似的对象,如果尺寸需要,使用寻呼机
%page -r obj
-- display object similar to print, using pager if size requires
%page
只能使用普通名称或属性引用。它无法评估任意表达式,但您可以使用临时变量来解决此限制。
%page
can only take a plain name or attribute reference. It cannot evaluate an arbitrary expression, but you can use a temporary variable to work around this limitationL
tmp = ex * pr + ess - ion
%page tmp
这篇关于如何在ipython中使用Pipe的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!