On 10 Mar 2009, at 10:33 AM, Michael S. Gilbert wrote: > On Tue, 10 Mar 2009 17:21:23 +0100, Mark Bakker wrote: >> Hello, >> >> I want to convert an array to a string. >> >> I like array2string, but it puts these annoying square brackets >> around >> the array, like >> >> [[1 2 3], >> [3 4 5]] >> >> Anyway we can suppress the square brackets and get (this is what is >> written with savetxt, but I cannot get it to store in a variable) >> 1 2 3 >> 4 5 6
How about using StringIO: >>> a = np.array([[1,2,3],[4,5,6]]) >>> f = StringIO() >>> savetxt(f, a, fmt="%i") >>> s = f.getvalue() >>> f.close() >>> print s 1 2 3 4 5 6 Michael. _______________________________________________ Numpy-discussion mailing list Numpy-discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion