无法通过切片在hdf5文件中设置数据集名称

时间:2019-06-16 12:48:20

标签: hdf5 python-3.7 h5py

我正在尝试通过取消h5py的格式将3个数据集存储在hdf5文件中。每个数据集的名称都带有切片,但这是行不通的。


# First I open a .png image file and convert this image to an numpy array
# called "raster":
.
.
.
# The second step is, that i'm trying to extract the datasetname by a slicing
# on the filename to give the dataset a name:

filename = imagefile1.png

dsetName = filename[:-4]

# Then i open a hdf5 file by:

file = h5py.File('hdf5_file.5h', 'a')

# and write the dataset into that file:

file.create_dataset(dsetName, data=raster)

但是在这一点上,我总是遇到相同的问题:

AttributeError:“切片”对象没有属性“编码”

0 个答案:

没有答案