Python打印或者保存一个很大的列表时,只能打印出来部分数据,中间数据以省略号形式输出,以打印出五亿以内的偶数为例:
代码如下:
a = np.arange(500000000)b = a[::2]print b
输出结果如下:
[ 0 2 4 ..., 499999994 499999996 499999998]
Running time: 3.65640311884 Seconds
解决方法:
加一句:np.set_printoptions(threshold='nan')# 全部输出 ,数据量太大,运行时间会很长
全部代码如下:
import numpy as npa = np.arange(500000000)b = a[::2]np.set_printoptions(threshold='nan')print b