Python文件读取报错:UnicodeDecodeError: ‘gbk‘ codec can‘t decode byte 0xa8 in position 10: illegal multibyt

Python文件读取报错:UnicodeDecodeError: 'gbk' codec can't decode byte 0xa8 in position 10: illegal multibyte sequence

使用with open(“goods.txt”,“r”)as file:语句读取文件时

请添加图片描述解决方法

with open("goods.txt","r",encoding='UTF-8')as file:
    content=file.readlines()
    for item in content:
        print(item)

加上encoding=‘UTF-8’
Python文件读取报错:UnicodeDecodeError: ‘gbk‘ codec can‘t decode byte 0xa8 in position 10: illegal multibyt_第1张图片
问题解决

你可能感兴趣的:(Python,python)