UnicodeDecodeError: 'gbk' codec can't decode byte 0x86 in position 136: illegal multibyte sequence
时间: 2023-10-16 07:21:06 浏览: 80
This error message indicates that the Python interpreter is unable to decode a byte string using the "gbk" codec. Specifically, it encountered a byte with value 0x86 at position 136, which does not form a valid multi-byte sequence according to the GBK character encoding.
To resolve this error, you may need to determine the correct character encoding for the input data and use that codec instead. Alternatively, you can try using a more robust codec such as "utf-8" which can handle a wider range of characters.
Here is an example of how to handle this error using the "utf-8" codec:
```
with open('myfile.txt', encoding='utf-8') as f:
data = f.read()
```
This code opens a file named 'myfile.txt' and reads its contents using the "utf-8" codec. If the file contains non-UTF-8 characters, they will be replaced with a special replacement character instead of causing a decoding error.
阅读全文