我會檢查的前10個字節對的描述的測試文件中np.lib.format
和C++代碼
從format.py
文件文檔頭的局部引用
Format Version 1.0
------------------
The first 6 bytes are a magic string: exactly ``\\x93NUMPY``.
The next 1 byte is an unsigned byte: the major version number of the file
format, e.g. ``\\x01``.
The next 1 byte is an unsigned byte: the minor version number of the file
format, e.g. ``\\x00``. Note: the version of the file format is not tied
to the version of the numpy package.
The next 2 bytes form a little-endian unsigned short int: the length of
the header data HEADER_LEN.
我還沒有用另一種語言編寫這個代碼,但是確實想看看那些想在同一個文件中保存幾個數組的SO的頭文件。
loading arrays saved using numpy.save in append mode
我認爲這將是明智的,用(A)一些廣泛支持的矩陣的文件格式,例如[其中之一(http://docs.scipy.org/doc/scipy/reference/io。或者(B)寫一些自定義的代碼。 – sascha
寫入.npy的代碼是Python,應該很容易確定頭部大小。尋找類似'lib/format.py'的東西。如果你沒有numpy,看看github倉庫。 – hpaulj