import h5py #added
hf = h5py.File('../images.h5', 'w') #added
hf.close() #added
h5_file = tables.open_file("images.h5", mode="w")
我也试过:
h5py.File.close(hf)
在这两种情况下弹出的错误是:
ValueError: The file 'restricted_images.h5' is already opened. Please close it before reopening in write mode.
我也试过:
if isinstance(obj, h5py.File): # Just HDF5 files
obj.close()
尽管
In[]: hf
Out[]: <Closed HDF5 file>
,文件尚未关闭。