連番で"ファイル_数字.hdf5"となっているファイルの特定の部分を一気に読み取りたいのですがコードがわかりません。
pytohn
1import h5py 2import matplotlib.pyplot as plt 3 4list=[] 5for i in range (100): 6 hdf5 = h5py.File("file_%d.hdf5", 'r') %(i) 7 list.append(hdf5["key"].value[0]) 8 9 print list
と書いたらいけるかと思いましたが
IOError: Unable to open file (unable to open file: name = 'file_%d.hdf5', errno = 2, error message = 'No such file or directory', flags = 0, o_flags = 0)
となり表示されません。
ちなみにひとつの場合は
python
1import h5py 2 3hdf5 = h5py.File("file_0.hdf5", 'r') 4print(hdf5["key"].value[0]) 5
で表示されます。
動作環境はpython2.7
windows10です。
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2018/11/01 10:13
2018/11/01 10:14