本文介绍了IPython交互式shell输出格式配置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如果有快速解决方法,请提前道歉。在IPython shell中,如果我有这个:
If there's a quick fix for this, apologies in advance. In the IPython shell, if I have this:
In [1]: x = [i for i in range(100)]
然后,如果我调用它,我会在新行上打印出每个元素的列表:
then I get a list printed with each element on a new line if I call it:
In [2]: x
Out[2]: [0
1,
2,
依此类推至100.因为经常我正在呼唤物品而烦恼知道他们会有多长时间(并且不想事先检查,并且不希望我的最后一个命令被推开并且不在路上)。我怎样才能让它以普通python的方式打印出结果?即:
and so on down to 100. Irritating as hell because often I'm calling objects and don't know how long they'll be (and don't want to check beforehand, and don't want my last commands to get pushed up and out of the way). How can I get it to print that result the way it would in regular python? I.e.:
>>> x
[1,2,3,4,5,6,7,8,....
9,10,11, ..... 100]
推荐答案
你想要的是禁用漂亮的打印。
What you want is to disable pretty print.
$ ipython --help
[...]
--no-pprint
Disable auto auto pretty printing of results.
[...]
给出:
$ ipython --no-pprint
[...]
In [1]: x = [i for i in range(100)]
In [2]: x
Out[2]: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99]
这篇关于IPython交互式shell输出格式配置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!