How to print a Numpy array without brackets?

Framester picture Framester · Feb 20, 2012 · Viewed 58.6k times · Source

I want to convert a = [1,2,3,4,5] into a_string = "1 2 3 4 5". The real numpy array is quite big (50000x200) so I assume using for loops is too slow.

Answer

tito picture tito · Feb 20, 2012

You can use the join method from string:

>>> a = [1,2,3,4,5]
>>> ' '.join(map(str, a))
"1 2 3 4 5"