【发布时间】:2021-08-18 03:44:48
【问题描述】:
所以我试图访问 HDF5 文件的子目录中的条目。下面是我的代码
data = h5py.File(filename, 'r')
seqTags = []
for entry in data['somesebdir']:
seqTags.append(str(entry).replace("b'", "")[:-1])
seq_list_file.append(str(entry).replace("b'", "")[:-1])
如您所见,我使用replace 来获取b'something'` to get something. However I would like to avoid doing this. How do I just get the content within HDF5 file without having to worry about this b''``` 字符?
我已经尝试使用rb 选项访问它。还是一样。
【问题讨论】:
-
如果您可以将其转换为可重现的示例,那就太好了。现在我们只能猜测
entry是一个组还是一个数据集。也许您可以添加一些生成文件的行,然后使用这些行来读取它。否则这里的 cmets 仍然有点模糊和不确定
标签: python python-3.x hdf5