【python 存储数据 h5py | h5df】【jupyter notebook 大型中间结果存储】

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/github_36923418/article/details/86098642

前言:我们在使用python 进行大规模计算的时候,无论是在debug还是在使用jupyter notebook调试的时候,都会遇到“崩溃了!”这个问题!

           特别是,某一个程序需要计算很多内容,等很长时间,结果在最后时刻调试的时候崩溃了!!!

           使用python我们主要也是为了方便,但是并不是所有内容肯定用numpy的*.npy 格式存下来!这个时候就有了h5py这个东西!

简介:h5py有点像 matlab的mat一样的存在!可以存几乎任何格式的数据内容!!!并且采用*.keys() 也就是dict_作为索引调取对应内容!

1、存储

import h5py
file = h5py.File('all_info.h5','w')
# 写入
file.create_dataset('data', data = data)
file.create_dataset('label', data = label)
file.create_dataset('others',data = others)

file.close()

2、调用

import h5py
file = h5py.File('all_info.h5','r')
# 读取
data=file['data']
#如果不知道有哪些内容,那就查询下
print(file.keys())

file.close()

报错解决https://blog.csdn.net/github_36923418/article/details/86135392 TypeError: Object dtype dtype('O') has no native HDF5 equivalent

猜你喜欢

转载自blog.csdn.net/github_36923418/article/details/86098642