我是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