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

apache - 504 Gateway Time-out The server didn't respond in time. How to fix it? -

c# - .net WebSocket: CloseOutputAsync vs CloseAsync -

c++ - How to properly scale qgroupbox title with stylesheet for high resolution display? -