【问题标题】:hdf5 file opening error: "TypeError: 'type' object has no attribute '__getitem__'"hdf5文件打开错误:“TypeError:'type'对象没有属性'__getitem__'”
【发布时间】:2017-07-01 03:00:18
【问题描述】:

我一直在尝试在 Spider 下的 Python 2.7 中打开现有的 .h5 数据文件。但是,我的代码不断收到此错误,如下所示:

enter image description here

结果如下:

enter image description here

【问题讨论】:

  • 您能否将您的代码发布为 txt 而不是图像?所以帮助你的人更容易

标签: python-2.7 debugging hdf5 data-science


【解决方案1】:

您正在尝试使用“文件”类的名称为“/train”的项目。 “文件”类不是集合。我不明白你想在 6 行代码中做什么。 也许你的意思是

import h5py
import numpy as np

filename = 'train.h5'
# open file for Read/write
f = h5py.File(filename, 'r+')
# get group or dataset in h5 file
dataset = f["/train"]

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-12-04
    • 2012-10-15
    • 2014-01-16
    • 2017-02-27
    • 2018-01-28
    相关资源
    最近更新 更多