numpy.save(file,arr,allow_pickle=True,fix_imports=True)[source]¶Save an array to a binary file in NumPy.npy format.
| Parameters: | file : file, str, or pathlib.Path
allow_pickle : bool, optional
fix_imports : bool, optional
arr : array_like
|
|---|
Notes
For a description of the.npy format, see the module docstringofnumpy.lib.format or the NumPy Enhancement Proposalhttp://docs.scipy.org/doc/numpy/neps/npy-format.html
Examples
>>>fromtempfileimportTemporaryFile>>>outfile=TemporaryFile()
>>>x=np.arange(10)>>>np.save(outfile,x)
>>>outfile.seek(0)# Only needed here to simulate closing & reopening file>>>np.load(outfile)array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9])