Python Save All Array Values as Text

Asked 2 years ago, Updated 2 years ago, 15 views

print('z= ' + str(encoded_imgs))
f = open("test.txt",'w')
f.write(str(encoded_imgs))
f.close

I would like to save the array as text using this grammar.

However, because there are too many contents of the array, it is saved as follows in the text.

[[ 9.814232    2.3858259   1.1962464  ...  3.4777994   3.8491027
   7.6847544 ]

It is omitted as ... in the middle, so is there a way to store all the elements without omission?

python

2022-09-20 21:37

1 Answers

If encoded_imgs is a numpy array, change it to list or

You can add np.set_printoptions(threshold=np.inf) to the code.


2022-09-20 21:37

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.