2017-05-03 5 views
0

zipファイルをポイントするためにluigi.LocalTargetをオープンしようとしています(ハッシュを計算できるように)。残念ながら、私がそれを読むと、UnicodeDecodeErrorが得られます。これは、バイナリファイルとして開かれていないことを意味します。バイナリ読み取りモードでluigi.LocalTargetを開く(デコードエラー)

私は(ルイジなし)これを行うことができますし、それが正常に

file_path = luigi.LocalTarget('myfile.zip') 
with open(file_path, 'rb') as f: 
    data = f.read(1048576) 

作品しかし、私はこの

target = luigi.LocalTarget(file_path) 
with target.open('rb') as f: 
    data = f.read(1048576) 

を行う場合、私は、私は、Pythonを使用しています。この

--------------------------------------------------------------------------- 
UnicodeDecodeError      Traceback (most recent call last) 
<ipython-input-28-5240759ed677> in <module>() 
     1 target = luigi.LocalTarget(file_path) 
     2 with target.open('rb') as f: 
----> 3  data = f.read(1048576) 

/usr/local/Cellar/python3/3.6.1/Frameworks/Python.framework/Versions/3.6/lib/python3.6/codecs.py in decode(self, input, final) 
    319   # decode input (taking the buffer into account) 
    320   data = self.buffer + input 
--> 321   (result, consumed) = self._buffer_decode(data, self.errors, final) 
    322   # keep undecoded input until the next call 
    323   self.buffer = data[consumed:] 

UnicodeDecodeError: 'utf-8' codec can't decode byte 0xc3 in position 10: invalid continuation byte 

を取得します3.6およびluigi 2.6.1。

答えて

関連する問題