import h5py
import numpy as np
a = np.arange(5).reshape((1,1,1,5))
with h5py.File('test.h5', 'w') as f:
f['data'] = a
import h5py
import numpy as np
data = h5py.File('test.h5', 'r')
a = data['data'][:]
查看key:
> print(f.keys())
[u'data']
若打印结果如KeysView(
,则可以遍历输出:
> for k in data.keys():
> print(k)
data