【发布时间】:2019-11-11 11:53:03
【问题描述】:
有没有一种快速有效的方法可以将 hdf5 文件的根目录的所有属性复制到 python dict 中,还是我必须循环遍历它?
我现在做了
my_dict = dict(file.attrs.items())
【问题讨论】:
标签: dictionary attr h5py
有没有一种快速有效的方法可以将 hdf5 文件的根目录的所有属性复制到 python dict 中,还是我必须循环遍历它?
我现在做了
my_dict = dict(file.attrs.items())
【问题讨论】:
标签: dictionary attr h5py
https://docs.h5py.org/en/stable/high/attr.html
file.attr 是这些属性的类似字典的接口。所以复制应该就像从一本字典复制到另一本字典一样。但是你真的需要复制吗?
首先我会尝试:
your_dict.update(file.attr)
【讨论】: