f = open("D:\positive.txt") r = f.read() print(r) 

It turns out this error stack:

 Traceback (most recent call last): File "D:/perforce/Social/test4.py", line 2, in <module> r = f.read() File "D:\Minicanoda3\lib\encodings\cp1251.py", line 23, in decode return codecs.charmap_decode(input,self.errors,decoding_table)[0] UnicodeDecodeError: 'charmap' codec can't decode byte 0x98 in position 11943: character maps to <undefined> 

Reported as a duplicate by Twiss , jfs python-3.x Apr 26 '18 at 11:53 .

A similar question was asked earlier and an answer has already been received. If the answers provided are not exhaustive, please ask a new question .

  • one
    try f = open("D:\positive.txt", encoding='utf-8') - Twiss

1 answer 1

 f = open("D:\positive.txt", encoding='utf-8') r = f.read() print(r)