https://github.com/affinelayer/pix2pix-tensorflow/tree/master/tools錯誤的UnicodeDecodeError:上述網站編譯「process.py」無效時起始字節
出現錯誤:「UTF-8」編解碼器不能在位置0解碼字節0xFF。
python tools/process.py --input_dir data -- operation resize --outp
ut_dir data2/resize
data/0.jpg -> data2/resize/0.png
回溯(最近通話最後一個):
File "tools/process.py", line 235, in <module>
main()
File "tools/process.py", line 167, in main
src = load(src_path)
File "tools/process.py", line 113, in load
contents = open(path).read()
File"/home/user/anaconda3/envs/tensorflow_2/lib/python3.5/codecs.py", line 321, in decode
(result, consumed) = self._buffer_decode(data, self.errors, final)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xff in position 0: invalid start byte
什麼是錯誤的原因是什麼? Python的版本是3.5.2。
我得到的錯誤: – Unnikrishnan
@Unnikrishnan好,然後用' 「ValueError異常模式字符串必須以 'R', 'W', 'A' 或 'U',而不是 'BR' 的一個開始」 rb'(我認爲順序並不重要,但似乎至少在某些系統/版本中)。我相應地改變了我的答案。 – Alfe
位置0處的字節0xff也可能意味着文件以UTF-16編碼,那麼您可以使用open(path,encoding ='utf-16')作爲f:'而不是 –