0

如果对此有快速解决方案,请提前道歉。在 IPython shell 中,如果我有这个:

In [1]: x = [i for i in range(100)]

然后如果我调用它,我会在新行上打印一个包含每个元素的列表:

In [2]: x
Out[2]: [0
        1,
        2,

依此类推,一直到 100。烦人,因为我经常调用对象并且不知道它们会持续多久(并且不想事先检查,也不希望我的最后一个命令被推高并且不碍事)。我怎样才能让它像在常规 python 中那样打印结果?IE:

>>> x
[1,2,3,4,5,6,7,8,....
9,10,11, ..... 100]
4

1 回答 1

1

你想要的是禁用漂亮的打印。

$ 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]
于 2013-03-05T20:35:04.627 回答