我是Python 3新手。如何在Python 3中打印numpy 2d数组?
我的代码如下,我不知道如何解决这个问题。
test = np.random.randn(10)
print (test)
TypeError: '>' not supported between instances of 'int' and 'str'
(+) 我已经导入numpy的,并且详细的错误味精以下。
TypeError Traceback (most recent call last)
<ipython-input-13-3e506a0fbc4a> in <module>()
1 test=np.random.randn(10)
----> 2 print(test)
/usr/local/lib/python3.6/site-packages/numpy/core/numeric.py in array_str(a, max_line_width, precision, suppress_small)
1937
1938 """
-> 1939 return array2string(a, max_line_width, precision, suppress_small, ' ', "", str)
1940
1941
/usr/local/lib/python3.6/site-packages/numpy/core/arrayprint.py in wrapper(self, *args, **kwargs)
386 repr_running.add(key)
387 try:
--> 388 return f(self, *args, **kwargs)
389 finally:
390 repr_running.discard(key)
/usr/local/lib/python3.6/site-packages/numpy/core/arrayprint.py in array2string(a, max_line_width, precision, suppress_small, separator, prefix, style, formatter)
521 else:
522 lst = _array2string(a, max_line_width, precision, suppress_small,
--> 523 separator, prefix, formatter=formatter)
524 return lst
525
/usr/local/lib/python3.6/site-packages/numpy/core/arrayprint.py in _array2string(a, max_line_width, precision, suppress_small, separator, prefix, formatter)
344 prefix="", formatter=None):
345
--> 346 if a.size > _summaryThreshold:
347 summary_insert = "..., "
348 data = _leading_trailing(a)
TypeError: '>' not supported between instances of 'int' and 'str'
您显示的代码运行良好。你确定这是什么产生了这个错误?我没有看到任何连接。 – hpaulj
这有帮助。你有没有改变numpy打印选项?它看起来像阈值是一个字符串,而不是一个数字。 – hpaulj