error UnicodeDecodeError: 'utf-8' codec can't decode byte 0xff in position 0: invalid start byte
程序员文章站
2024-02-22 11:43:04
...
最近在研究tensorflow的工程,遇到一些小白鼠错误,记录一下。
问题:error UnicodeDecodeError: 'utf-8' codec can't decode byte 0xff in position 0: invalid start byte
解决:
def _process_image(filename, coder):
with tf.gfile.FastGFile(filename, 'r') as f:
image_data = f.read()
# image_data = image_data.rstrip("\n").decode("utf-16")
# image_data = image_data.split("\r\n")
image = coder.decode_png(image_data)
修改为:
def _process_image(filename, coder):
with tf.gfile.FastGFile(filename, 'rb') as f:
image_data = f.read()
# image_data = image_data.rstrip("\n").decode("utf-16")
# image_data = image_data.split("\r\n")
image = coder.decode_png(image_data)
推荐阅读
-
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xff in position 0: invalid start byte
-
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xff in position 0: invalid start byte解决方法
-
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xff in position 0: invalid start byte 问题
-
error UnicodeDecodeError: 'utf-8' codec can't decode byte 0xff in position 0: invalid start byte
-
调试错误:UnicodeDecodeError: 'utf-8' codec can't decode byte 0xff in position 0: invalid start byte
-
pickle报UnicodeDecodeError: ‘ascii‘ codec can‘t decode byte 0xff in position 0:
-
Anaconda中启动Python时的错误:UnicodeDecodeError: 'gbk' codec can't decode byte 0xaf in position 553
-
UnicodeDecodeError: ‘ascii‘ codec can‘t decode byte 0xcb in position 260: ordinal not in range(128)
-
命令行调用python出现编码错误:UnicodeDecodeError: ‘gbk‘ codec can‘t decode byte 0x9a in position 140 完美解决!
-
Python2.7更新pip:UnicodeDecodeError: 'ascii' codec can't decode byte 0xb7 in position 7: ordinal not in range(128)