
请问怎么删除bostonHousing,
import h5py
with h5py.File('/model_outputs_non_svi.h5', 'a') as h5_file:
del h5_file['bostonHousing']
这个代码不管用

请问怎么删除bostonHousing,
import h5py
with h5py.File('/model_outputs_non_svi.h5', 'a') as h5_file:
del h5_file['bostonHousing']
这个代码不管用
阿里嘎多学长整理AIGC生成,因移动端显示问题导致当前答案未能完全显示,请使用PC端查看更加详细的解答过程
你可以使用 del 语句来删除 HDF5 文件中的组。下面是一个示例:
import h5py
with h5py.File('/model_outputs_non_svi.h5', 'a') as h5_file:
del h5_file['bostonHousing']
这将删除名为 bostonHousing 的组。
如果你想要删除整个文件,可以使用 os 模块:
import os
os.remove('/model_outputs_non_svi.h5')
请注意,在删除文件之前,确保你已经关闭了 HDF5 文件的读写操作。