解决’gbk’ codec can’t decode byte 0xbf in position 2报错:
报错信息如下:

报错了一大堆,其实只有一个地方错了,通过debug调试,得知:

只需将dataloader.py内的dataset.py内置代码:
with open(gt_path) as f:
改为:
with open(gt_path, encoding='utf-8-sig') as f:
即可
本文解决了一个常见的Python文件读取问题,即'gbk’codeccan’tdecodebyte0xbfinposition2的解码错误。通过调整文件打开方式,指定正确的编码格式为'utf-8-sig',成功解决了该问题。
解决’gbk’ codec can’t decode byte 0xbf in position 2报错:
报错信息如下:

报错了一大堆,其实只有一个地方错了,通过debug调试,得知:

只需将dataloader.py内的dataset.py内置代码:
with open(gt_path) as f:
改为:
with open(gt_path, encoding='utf-8-sig') as f:
即可
1927
9698
3047
8551
7725

被折叠的 条评论
为什么被折叠?