RELATEED CONSULTING
相关咨询
选择下列产品马上在线沟通
服务时间:8:30-17:00
你可能遇到了下面的问题
关闭右侧工具栏

新闻中心

这里有您想知道的互联网营销解决方案
创新互联Python教程:python如何查看hdf5文件

说明

创新互联专注网站设计,以设计驱动企业价值的持续增长,网站,看似简单却每一个企业都需要——设计,看似简洁却是每一位设计师的心血 十年来,我们只专注做网站。认真对待每一个客户,我们不用口头的语言来吹擂我们的优秀,千余家的成功案例见证着我们的成长。

1、HDF5不支持用其他浏览器打开,建议写一个代码来进行读取。 

2、读取HDF5文件中的所有数据集,然后传输到路径。

实例

# 读取HDF5文件中的所有数据集
def traverse_datasets(hdf_file):
    import h5py
 
    def h5py_dataset_iterator(g, prefix=''):
        for key in g.keys():
            item = g[key]
            path = '{}/{}'.format(prefix, key)
            if isinstance(item, h5py.Dataset): # test for dataset
                yield (path, item)
            elif isinstance(item, h5py.Group): # test for group (go down)
                yield from h5py_dataset_iterator(item, path)
 
    with h5py.File(hdf_file, 'r') as f:
        for (path, dset) in h5py_dataset_iterator(f):
            print(path, dset)
 
    return None
 
# 传入路径即可
traverse_datasets('datasets/train_catvnoncat.h5')

以上就是python查看hdf5文件的方法,希望对大家有所帮助。更多Python学习指路:创新互联python教程

本文教程操作环境:windows7系统、Python 3.9.1,DELL G3电脑。


网站题目:创新互联Python教程:python如何查看hdf5文件
网页路径:http://www.jxjierui.cn/article/dhdepgj.html