https://github.com/affinelayer/pix2pix-tensorflow/tree/master/tools

在上面的站点上编译“process.py”时发生错误。

 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。


当前回答

我在处理从Linux生成的文件时遇到了同样的问题。事实证明,这与包含问号的文件有关。

其他回答

如果你在mac上,检查是否有一个隐藏文件,. ds_store。删除文件后,我的程序工作。

以下代码在我的情况下工作:

Df = pd。Read_csv (filename,sep =' \t', encoding='cp1252')

如果可能,在文本编辑器中打开该文件,并尝试将编码更改为UTF-8。否则,在操作系统级别以编程方式进行。

检查要读取的文件的路径。我的代码不断给我错误,直到我改变路径名,以呈现工作目录。错误是:

newchars, decodedbytes = self.decode(data, self.errors)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xff in position 0: invalid start byte

我有一个类似的问题,并在互联网上搜索这个问题

如果你有这个问题,只需复制你的HTML代码在一个新的HTML文件,并使用正常的<meta charset="UTF-8"> 它将工作....

只需在相同的位置创建一个新的HTML文件,并使用不同的名称