在C++中:
std::string filename = "foo.h5";
if(!H5::H5File::isHdf5(filename.c_str()))
{
std::string err_msg = filename + " is not an HDF5 file.\n";
throw std::logic_error(err_msg);
}
import h5py
if not h5py.is_hdf5('foo.h5'):
raise ValueError('Not an hdf5 file')