LoginSignup
18
6

More than 3 years have passed since last update.

pythonでcodec can't decode byteが出たときのこと

Posted at

こんなエラーが出る

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

こういうときはエンコードを指定する

f = open(filename, encoding='CP932')
encode
UTF-8
Shift_JIS
EUC-JIS
ISO-2022-JP
CP932

Shift_JISって聞いてるのにエラーになるとき

CP932を指定したらうまくいくかも(重要)

18
6
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
18
6