How can I save a matrix in a txt file and then open it again as a matrix in python? -


"Directory" a = np. Array ([[1,2,3], [1,2,3]] OSCHDIR (Outrear) NPSVettext ("Image Bean", A) F = Open ("Directory / Image. Bin") m = np.fromfile (F, dtype = np.uint16) print lain (m) ma = np. Array (np fresh (m, (2,3)) print print

but this error message Is: "The total size of the new array should be unchanged"

I tried to change the dtype, but it did not work

<

You should use np.loadtxt :

Try:

 Np.savetxt ("Image.bin", a) m = np.loadtxt ("(" [2] [2] Image.bin ")  < / Pre> 

m now has the same array as a .


Comments

Popular posts from this blog

HTML/CSS - Automatically set height width from background image? -

php - Mysql Show Process - Sleep Commands and what to do -

c - What is the address of buf (the local variable in the main function)? -