0
.HDF5 데이터 파일 목록을 반복하고 그 후에 일부 작업을 수행하고 싶습니다. 그래서 각 파일마다 개별적으로 작업을하지 않으려면 루프를 반복하고 싶습니다. 나는 그 후 다음 ...은 HDF5 파일 목록을 반복합니다.
import os
import h5py
# Read in 2A.GPM.DPR
os.chdir('/home/unix/Desktop/source')
file_name = ['2A.GPM.DPR.V6-20160118.20150620-S060925-E074157.007431.V04A.HDF5',
'2A.GPM.DPR.V6-20160118.20150801-S100900-E114133.008087.V04A.HDF5']
for n in file_name:
print n
#
f = h5py.File(file_name, 'r')
##
나는 다음과 같은 오류
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-26-e6813194d502> in <module>()
6 print n
7 #
----> 8 f = h5py.File(file_name, 'r')
/home/unix/anaconda2/lib/python2.7/site-packages/h5py/_hl/files.pyc in __init__(self, name, mode, driver, libver, userblock_size, swmr, **kwds)
265 # encoding, just pass it on as-is. Note Unicode
266 # objects can always be encoded.
--> 267 name = name.encode(sys.getfilesystemencoding())
268 except (UnicodeError, LookupError):
269 pass
AttributeError: 'list' object has no attribute 'encode'
그래서이 오류가 될 수있는 것을 알 수 있습니까 되었나요? 도움을 주셔서 감사합니다.
예, 작동합니다. verry 많이 감사합니다! – Markus