[Numpy-discussion] printing array in tabular form
Henry Gomersall
heng at cantab.net
Fri May 10 07:59:07 EDT 2013
On Fri, 2013-05-10 at 17:14 +0800, Sudheer Joseph wrote:
> Thank you,
> But I was looking for a format statement likw
> write(*,"(A,5F8.3)")
> with best regards,
> Sudheer
How about the following:
print('IL = ' + (('%d,' * 5)[:-1] + '\n ') * 5 % tuple(IL))
If instead of a list IL you had some arbitrary 2D array, a, you could do
(with 2 lines for clarity):
print_string = 'a = ' + (('%d,' * a.shape[1])[:-1] + '\n ') *
a.shape[0] % tuple(a.T.ravel())
print(print_string)
I'll leave it as an exercise for you to put that into a file.
hen
More information about the NumPy-Discussion
mailing list