python存储数据的方式_python – 数据存储在* .npy中的方式是什么?
npy文件格式记录在numpy的https://github.com/numpy/numpy/blob/master/doc/neps/npy-format.rst中.例如,代码>>> dt=numpy.dtype([('outer','(3,)...('outer2',[('inner','(10,)>>> a=numpy.a...
npy文件格式记录在numpy的
https://github.com/numpy/numpy/blob/master/doc/neps/npy-format.rst中.
例如,代码
>>> dt=numpy.dtype([('outer','(3,)
... ('outer2',[('inner','(10,)
>>> a=numpy.array([((1,2,3),((10,11,12,13,14,15,16,17,18,19),3.14)),
... ((4,5,6),((-1,-2,-3,-4,-5,-6,-7,-8,-9,-20),6.28))],dt)
>>> numpy.save('1.npy', a)
导致文件:
93 4E 55 4D 50 59 magic ("\x93NUMPY")
01 major version (1)
00 minor version (0)
96 00 HEADER_LEN (0x0096 = 150)
7B 27 64 65 73 63 72 27
3A 20 5B 28 27 6F 75 74
65 72 27 2C 20 27 3C 69
34 27 2C 20 28 33 2C 29
29 2C 20 28 27 6F 75 74
65 72 32 27 2C 20 5B 28
27 69 6E 6E 65 72 27 2C
20 27 3C 69 34 27 2C 20
28 31 30 2C 29 29 2C 20
28 27 69 6E 6E 65 72 32 Header, describing the data structure
27 2C 20 27 3C 66 38 27 "{'descr': [('outer', '
29 5D 29 5D 2C 20 27 66 ('outer2', [
6F 72 74 72 61 6E 5F 6F ('inner', '
72 64 65 72 27 3A 20 46 ('inner2', '
61 6C 73 65 2C 20 27 73 )],
68 61 70 65 27 3A 20 28 'fortran_order': False,
32 2C 29 2C 20 7D 20 20 'shape': (2,), }"
20 20 20 20 20 20 20 20
20 20 20 20 20 0A
01 00 00 00 02 00 00 00 03 00 00 00 (1,2,3)
0A 00 00 00 0B 00 00 00 0C 00 00 00
0D 00 00 00 0E 00 00 00 0F 00 00 00
10 00 00 00 11 00 00 00 12 00 00 00
13 00 00 00 (10,11,12,13,14,15,16,17,18,19)
1F 85 EB 51 B8 1E 09 40 3.14
04 00 00 00 05 00 00 00 06 00 00 00 (4,5,6)
FF FF FF FF FE FF FF FF FD FF FF FF
FC FF FF FF FB FF FF FF FA FF FF FF
F9 FF FF FF F8 FF FF FF F7 FF FF FF
EC FF FF FF (-1,-2,-3,-4,-5,-6,-7,-8,-9,-20)
1F 85 EB 51 B8 1E 19 40 6.28
开放原子开发者工作坊旨在鼓励更多人参与开源活动,与志同道合的开发者们相互交流开发经验、分享开发心得、获取前沿技术趋势。工作坊有多种形式的开发者活动,如meetup、训练营等,主打技术交流,干货满满,真诚地邀请各位开发者共同参与!
更多推荐
所有评论(0)