原文:https://docs.scipy.org/doc/numpy/reference/generated/numpy.save.html
校对:(虚位以待)
numpy.
save
(file, arr, allow_pickle=True, fix_imports=True)[source]将数组以NumPy .npy
格式保存到二进制文件。
参数: | 文件:文件或str
allow_pickle:bool,可选
fix_imports:bool,可选
arr:array_like
|
---|
笔记
有关.npy
格式的说明,请参阅numpy.lib.format
的模块docstring或Numpy增强提议http://docs.scipy.org /doc/numpy/neps/npy-format.html
例子
>>> from tempfile import TemporaryFile
>>> 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])