UnicodeDecodeError: 'gbk' codec can't decode byte 0x98 in position 32: illegal multibyte sequence
时间: 2023-10-16 11:19:19 浏览: 337
This error occurs when Python tries to decode a string using the gbk codec, but encounters a byte that is not a valid character in that encoding.
To fix this error, you can try using a different encoding that supports the characters in the string, or you can try to clean the string by removing any invalid characters before decoding it.
For example, you could try decoding the string using the utf-8 encoding instead of gbk:
```
my_string = b'\xb5\xea\xc7\xeb\xcd\xf8\xd5\xbe\xcf\xe0\xb9\xfa\x98'
decoded_string = my_string.decode('utf-8')
```
If you need to clean the string first, you could use the following code:
```
my_string = b'\xb5\xea\xc7\xeb\xcd\xf8\xd5\xbe\xcf\xe0\xb9\xfa\x98'
cleaned_string = my_string.replace(b'\x98', b'').decode('gbk')
```
阅读全文