【问题标题】:h5py Ignore external links when reading fileh5py 读取文件时忽略外部链接
【发布时间】:2015-10-13 17:05:56
【问题描述】:

我正在一个组中读取 hdf5 文件,其中一些组成员是外部链接。我希望能够识别哪些组成员是外部链接,然后忽略它们以供进一步阅读。

示例代码:

f = h5py.File(filename, 'r')
data = f['header']
for p in date.keys:
    (if p is an external link, detect it here!)

【问题讨论】:

  • 我正在使用 get(name, default=None, getclass=False, getlink=False) 来检索它是否是外部链接。如果我打印我得到的类型,例如 。我应该在 if 语句中添加什么来获取外部链接位?

标签: python hdf5 h5py


【解决方案1】:

工作代码:

f = h5py.File(filename, 'r')
data = f['header']
for p in date.keys:
    if bool('h5py._hl_.group.ExternalLink' in str(type(data.get(p, getlink=True))))):
        print 'External link found!'

漂亮的pythonic,我知道... ;)

【讨论】:

    猜你喜欢
    • 2023-01-05
    • 2015-11-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-04-18
    • 2020-10-27
    • 2019-07-27
    相关资源
    最近更新 更多