python读取npy文件_python – 如何在磁盘上创建一个numpy .npy文件?
當(dāng)我讀到Sven的回復(fù)時,我也有同樣的問題,感到失望.似乎numpy將錯過一些關(guān)鍵的功能,如果你不能有一個巨大的數(shù)組文件,并在一小塊工作一次.您的案例似乎接近使用.npy格式的原始理性的一個用例(參見:
http://svn.scipy.org/svn/numpy/trunk/doc/neps/npy-format.txt).
然后我碰到了numpy.lib.format,這似乎是有用的好東西.我不知道為什么這個功能是不可用的numpy根包.與HDF5相比,它的主要優(yōu)點在于它帶有麻煩.
>>> print numpy.lib.format.open_memmap.__doc__
"""
Open a .npy file as a memory-mapped array.
This may be used to read an existing file or create a new one.
Parameters
----------
filename : str
The name of the file on disk. This may not be a filelike object.
mode : str, optional
The mode to open the file with. In addition to the standard file modes,
'c' is also accepted to mean "copy on write". See `numpy.memmap` for
the available mode strings.
dtype : dtype, optional
The data type of the array if we are creating a new file in "write"
mode.
shape : tuple of int, optional
The shape of the array if we are creating a new file in "write"
mode.
fortran_order : bool, optional
Whether the array should be Fortran-contiguous (True) or
C-contiguous (False) if we are creating a new file in "write" mode.
version : tuple of int (major, minor)
If the mode is a "write" mode, then this is the version of the file
format used to create the file.
Returns
-------
marray : numpy.memmap
The memory-mapped array.
Raises
------
ValueError
If the data or the mode is invalid.
IOError
If the file is not found or cannot be opened correctly.
See Also
--------
numpy.memmap
"""
總結(jié)
以上是生活随笔為你收集整理的python读取npy文件_python – 如何在磁盘上创建一个numpy .npy文件?的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: [pytorch、学习] - 3.5 图
- 下一篇: python发钉钉消息_Python调用