Python 读写UnicodeDecodeError: 'gbk' codec can't decode byte 0x80 in position 2: illegal multibyte sequence
字符流问题
open 的方式变为 二进制,也就是下面代码里的 open(filename,’rb’)
f = open('C:/Users/lenovo/Desktop/test.txt', 'rb') print(f.read().decode('utf-8')) f = open('C:/Users/lenovo/Desktop/test.txt', 'r') print(f.read())