UnicodeDecodeError: ‘utf-8’ codec can’t decode byte 0xbc in position 0: inva
今天python读取txt文档的时候遇到这个报错,这个是编解码的问题,改成encoding='gbk’即可,因为txt文件里面就是这么编码的
with open('images/test_images/labels.txt','r', encoding='gbk') as f:
for line in f.readlines():
line = line.strip()
text_txt.append(line)
ocr_number += len(line)