I have an array formatted like this:
[-22.99253267 -83.23210952 77.71126322 43.99377722 -41.75731176 89.02862477]
I would like to print this array to receive this result
[-22.992 -83.232 77.711 43.993 -41.757 89.028]
I know It will be a similar result if I use np.set_printoptions(precision=3), but I would like to know how to receive this result using 9.3f.
To print the data in column :
for data in x:
print '{:9.3f}'.format(data)
or
To print the data in row :
(don't forget import sys)
for data in x:
sys.stdout.write('{:9.3f}'.format(data))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With