h5f.create_dataset
时间: 2024-01-13 22:05:36 浏览: 79
create-dataset
h5f.create_dataset is a method in the h5py Python library that creates a new dataset in a HDF5 file. The method takes three arguments - name, shape, and dtype - that define the properties of the dataset.
The name argument specifies the name of the dataset within the HDF5 file. The shape argument specifies the dimensions of the dataset, which is a tuple of integers. The dtype argument specifies the data type of the elements in the dataset.
Here is an example usage of the h5f.create_dataset method:
```
import h5py
with h5py.File('example.hdf5', 'w') as f:
dset = f.create_dataset('my_dataset', shape=(10,), dtype='i')
```
This code creates a new HDF5 file called 'example.hdf5' and a dataset called 'my_dataset' with 10 integer elements. The dataset is stored in the variable 'dset'.
阅读全文