长NumPy数组无法完全打印? [英] Long NumPy array can't be printed completely?

查看:279
本文介绍了长NumPy数组无法完全打印?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试打印两个1001x1数组的完整内容,但是Python仅给我截断的输出,如下所示:

I'm trying to print the complete contents of two 1001x1 arrays, but Python only gives me truncated output something like this:

array([[5,45],
       [1,23],
       ......,
       [1,24],
       [2,31]])  

而不是完整的数组.

任何人都可以给我解决方案,以获取完整的1001x1阵列吗?

Can anyone give me solution of how to get the complete 1001x1 array?

推荐答案

我猜您尝试了一个简单的语句,例如:

I'm going to guess that you tried a simple statement like:

print myarray

...而不是更明确的内容:

... rather than something more explicit like:

for each_item in myarray:
    print each_item

...甚至:

print ', '.join([str(x) for x in myarray])

您可能会看到输出消失的原因大概是因为numpy在其array类中实现了 _str_ 方法,该方法试图提供合理的"默认值 数组的字符串表示形式.据推测,它们假设简单的print语句将主要用于调试,记录或类似目的,并且将使用更明确的迭代来完成结果的报告或将结果编组到其他进程或存储中.数据(如我在此处所示).

The reason you're seeing elided output is, presumably, because numpy implements a _str_ method in its array class which tries to give a "reaasonable" default string representation of the array. They are, presumably, assuming that simple print statements will be used primarily for debugging, logging, or similar purposes and that reporting of results, or marshaling of results to other processes or storage, is going to be done using more explicit iterations over the data (as I've shown here).

这篇关于长NumPy数组无法完全打印?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆