When codec can't decode byte appears in python

I get this error

UnicodeDecodeError: 'utf-8' codec can't decode byte 0x98 in position 6615: invalid start byte
UnicodeDecodeError: 'shift_jis' codec can't decode byte 0xff in position 4729: illegal multibyte sequence

In such a case, specify the encoding


f = open(filename, encoding='CP932')

When I hear Shift_JIS but get an error

If you specify CP932, it may work (important)

Recommended Posts

When codec can't decode byte appears in python
Mecab --UnicodeDecodeError:'utf8' codec can't decode byte
UnicodeDecodeError:'ascii' codec can't decode byte 0xa4 in position 0: ordinal not in range (128)
UnicodeDecodeError: What to do when'shift_jis' codec can't decode byte
Attention when os.mkdir in Python
yum throws "UnicodeDecodeError:'ascii' codec can't decode byte 0xc3 in position 15: ordinal not in range (128)" error
What to do when "SSL: CERTIFICATE_VERIFY_FAILED _ssl.c: 1056" appears in Python
'Ascii' codec can't encode characters in position xx-xx: ordinal not in range (128) when calling PHP → Python
Precautions when using pit in Python
Behavior when listing in Python heapq
I can't install scikit-learn in Python
When using regular expressions in Python
When writing a program in Python
I get a can't set attribute when using @property in python
UnicodeDecodeError:'utf-8' codec ca n’t decode byte 0x91 in position 1: invalid start byte
When specifying multiple keys in python sort
When you can't call base.html in Django
Create ScriptableObject in Python when building ADX2
Precautions when pickling a function in python
I can't debug python scripts in Eclipse
When looking at memory usage in Python 3
SyntaxError: (unicode error)'unicodeescape' codec can't decode bytes in position 2-3: truncated \ UXXXXXXXX escape
When Python "Syntax Error: Non-ASCII character ~" appears
Why can't I install matplotlib in python! !!
What to do when a warning appears around Python integration in Neovim's CheckHealth
[Python] What to check when you get a Unicode Decode Error in Django
What to do when [Errno 2] No such file or directory appears in Python
Today's python error: UnicodeEncodeError:'ascii' codec can't encode characters
File DL, byte value and delete in Python3
Avoiding "'ascii' codec can't decode" with pip install
When I try matplotlib in Python, it says'cairo.Context'
When Assertion `srcIndex <srcSelectDimSize` failed. Appears in TextGAN
Precautions when dealing with control structures in Python 2.6
Note on encoding when LANG = C in Python
Character encoding when dealing with files in Python 3
Split files when writing vim plugin in python
Today's python error: UnicodeEncodeError:'utf-8' codec can't encode characters
[Question] What happens when I use% in python?
Error when trying to install psycopg2 in Python
Behavior when saving python datetime object in MongoDB
Solution when module'XXX' has no attribute'XXX' in Python
Use pydantic when reading environment variables in Python
Python in optimization
CURL in python
When Attribute Error: Can't get attribute'class name' on <module'__main__' (built-in)> appears when loading python pickle
Metaprogramming in Python
Python 3.3 in Anaconda
Geocoding in python
SendKeys in Python
Meta-analysis in Python
Unittest in python
Epoch in Python
Discord in Python
Sudoku in Python
DCI in Python
quicksort in python
nCr in python
N-Gram in Python
Programming in python
Plink in Python
Constant in python