低级h5py h5f错误:应为字节,但找到s

2024-10-01 02:20:41 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在尝试使用修改的缓存设置创建hdf5文件处理程序,如下所示:

import h5py
import contextlib

def hdf5_handler(filename, mode="r"):
    h5py.File(filename, "a").close()
    propfaid = h5py.h5p.create(h5py.h5p.FILE_ACCESS)
    settings = list(propfaid.get_cache())
    settings[1] = 0
    settings[2] = 0
    propfaid.set_cache(*settings)
    with contextlib.closing(h5py.h5f.open(filename, fapl=propfaid)) as fid:
        return h5py.File(fid, mode)

#############
hdf5 = hdf5_handler("/tmp/foo.hdf5", "a")

但它给出了以下错误:

^{pr2}$

Python版本:3.5.5 h5py版本:“2.8.0”

我在下面也发现了类似的代码,但同样的错误也不适用于我: How to set cache settings while using h5py high level interface?


Tags: importcachesettingsmode错误filenamefilehdf5