(mac) python中UnicodeDecodeError: 'utf-8' codec can't decode byte 报错

因为mac新建一个txt(或者其他含有文本)的字符编码格式不是utf-8

可以进入终端,cd 文件路径,进行以下操作

iconv -c -f GBK -t UTF-8 test.txt(文件名) > test3.txt

就能成功了,见下图

猜你喜欢

转载自blog.csdn.net/qingfudian5382/article/details/89787934