How do I see what variables, datasets, etc. a given .h5 file has in Python?
I can read the file by running this
import h5py
f = h5py.File(filename, 'r')
How can I now see which variables my .h5 file have?
Running f.keys() outputs the non-informative
KeysView()
In Matlab I simply call h5disp(filename) but would like to know how to do it in Python
解决方案
Did you try?
print(list(f.keys()))
That should give you all the group inside your hdf5 file. You can do the same for the datasets if f is a group.
在Python中,使用h5py库读取.h5文件后,通过`f.keys()`可以获取文件中的组。若要查看数据集,可对组进行相同操作。在Matlab中,`h5disp(filename)`能直接显示文件详细信息,但在Python中,你需要打印`list(f.keys())`来查看所有组。这将帮助你了解.h5文件内的变量和数据集。

2227

被折叠的 条评论
为什么被折叠?



