python报错:UnicodeDecodeError: ‘gbk‘ codec can‘t decode byte 0xaf in position 解决方案

1、原代码:

data_path = "sources/weibo_senti_100k.csv"
data_list = open(data_path).readlines()[1:]

2、报错:
UnicodeDecodeError: ‘gbk’ codec can’t decode byte 0xaf in position 59

3、解决方案:

data_path = "sources/weibo_senti_100k.csv"
data_list = open(data_path,"r",encoding='UTF-8').readlines()[1:]

你可能感兴趣的:(自然语言处理,pytorch)