Python读取文件时报错:UnicodeDecodeError: 'gbk' codec can't decode byte 0x80 in position 4: illegal multibyt

根据提示,发现是编码不对,打开文件时改成utf-8编码,即可

open("test.txt","r",encoding="UTF-8", errors="ignore")

你可能感兴趣的:(Python读取文件时报错:UnicodeDecodeError: 'gbk' codec can't decode byte 0x80 in position 4: illegal multibyt)