import h5py
filename = "file.hdf5"
with h5py.File(filename, "r") as f:
# List all groups
print("Keys: %s" % f.keys())
a_group_key = list(f.keys())[0]
# Get the data
data = list(f[a_group_key])
import h5py
# Create random data
import numpy as np
data_matrix = np.random.uniform(-1, 1, size=(10, 3))
# Write data to HDF5
with h5py.File("file.hdf5", "w") as data_file:
data_file.create_dataset("group_name", data=data_matrix)
有关更多信息,请参见h5py docs。
XML:存在太多叹息(读与写 对于您的应用程序,以下内容可能很重要:
其他编程语言的支持
另请参阅:数据序列化格式的比较
如果您想寻找一种制作配置文件的方法,则可能需要阅读我的短文《Python中的配置文件》。