SciPy, arr)[source]

Save an array to a binary file in NumPy .npy format.

Parameters :

file : file or str

File or filename to which the data is saved. If file is a file-object, then the filename is unchanged. If file is a string, a .npy extension will be appended to the file name if it does not already have one.

arr : array_like

Array data to be saved.

See also

Save several arrays into a .npz archive

savetxt, load


For a description of the .npy format, see format.


>>> from tempfile import TemporaryFile
>>> outfile = TemporaryFile()
>>> x = np.arange(10)
>>>, x)
>>> # Only needed here to simulate closing & reopening file
>>> np.load(outfile)
array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9])

Previous topic


Next topic