python读取文件时提示"UnicodeDecodeError: ‘gbk’ codec can’t decode byte 0x80 in position 205: illegal multibyte sequence"
原代码:
file = open(r"D:\PythonSourceCode\ReadFile\abc.txt", "r")
data = file.read()
print(data)
file.close()
修改为:
file = open(r"D:\PythonSourceCode\ReadFile\abc.txt", "r", encoding='UTF-8')
data = file.read()
print(data)
file.close()