Avatar ·

Python: 'charmap' codec can't decode byte 0x98

📁 итератор, python, ошибка, пример, работа

Hello. I'm reading a utf8 file and outputting it to the console. When trying to output the letter "И", an error occurs:

File "I:\\ProgramFile\\Anaconda\\lib\\encodings\\cp1251.py", line 15, in decode      retu codecs.charmap_decode(input,errors,decoding_table)  UnicodeDecodeError: 'charmap' codec can't decode byte 0x98 in position 1: character maps to < undefined >

It reproduces on this example:

test_text_1 = "Task"test_text_2 = "Iterator"file = open                    
Avatar ·
box_b = [7, 3, 9, 5]box_a = ['apple', 'banana', 'cherry', 'lemon']new_b, new_a = zip(*[(b, a) for b, a in sorted(zip(box_b, box_a))])print(new_b)(3, 5, 7, 9)print(new_a)('banana', 'lemon', 'apple', 'cherry')

Log in to leave an answer

Blogs