h5py如何存储字符串

h5py如何存储字符串
确定存储的数据类型,python3 vlen = str ,python 2 vlen=unicode。
新建数据库后,明确数组的维度,传入类型,再赋值。

dt = h5py.special_dtype(vlen=str)
data = np.array([['str1'],['str2']])
with h5py.File('mydata.h5','w') as f:
    ds = f.create_dataset('test_dict', data.shape , dtype=dt)

猜你喜欢

转载自blog.csdn.net/weixin_37707670/article/details/119038651