- “unicodeDecodeError: ‘ascii’ codec can’t decode byte 0xe9 in position 146: ordinal not in range(128)”
解决方法: 添加 encoding=“utf08”
import os
import codecs
import sys
input_file = '/cephfs/group/teg-pot-ai-algorithm/katezhou/gen_sim_query/bert-master/'
data_dir = input_file
file_path = os.path.join(data_dir, 'train.txt')
with open(file_path, 'r', encoding='utf-8') as f:
reader = f.readlines()
examples = []
for index, line in enumerate(reader):
split_line = line.strip().split(',')
examples.append(split_line)
print('*************************examples',len(examples))
|