报错内容:
python报错:UnicodeDecodeError: ‘gbk‘ codec can‘t decode byte 0xaf in position
解决方案:
给函数加上一个参数:encoding='UTF-8'
open (os.path.join(data_dir, 'test.txt'), 'r')
open (os.path.join(data_dir, 'test.txt'), 'r',encoding='UTF-8')
报错内容:
python报错:UnicodeDecodeError: ‘gbk‘ codec can‘t decode byte 0xaf in position
解决方案:
给函数加上一个参数:encoding='UTF-8'
open (os.path.join(data_dir, 'test.txt'), 'r')
open (os.path.join(data_dir, 'test.txt'), 'r',encoding='UTF-8')
本文标题:UnicodeDecodeError: ‘gbk‘ codec
本文链接:https://www.haomeiwen.com/subject/hfhyortx.html
网友评论